Skip to content

Commit

Permalink
Add ai searching, animal list, public animal, save
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgehl3n committed Nov 3, 2023
1 parent e202cb7 commit 4720e7b
Show file tree
Hide file tree
Showing 38 changed files with 1,867 additions and 27 deletions.
72 changes: 72 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@types/redis": "^4.0.11",
"@types/sequelize": "^4.28.15",
"accesscontrol": "^2.2.1",
"axios": "^1.6.0",
"bcrypt": "^5.1.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.20.2",
Expand Down
16 changes: 16 additions & 0 deletions src/apis/AiBreedClassificationApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import dotenv from 'dotenv';

export default class AiBreedClassificationApi {
public static async Predict(image: Blob) {
const formData = new FormData();
formData.append('image', image);
const url = process.env.AI_BREED_URL || "";
if (url) {
const response = await fetch(url, {
method: 'POST',
body: formData,
});
return await response.json();
}
}
}
24 changes: 12 additions & 12 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ class Application {
}

private _setMiddlewares(): void {
if (process.env.NODE_ENV === 'production') {
// if (process.env.NODE_ENV === 'production') {
// this.express.use(cors({
// origin: process.env.FRONTEND_URL,
// credentials: true,
// methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
// optionsSuccessStatus: 200
// }));
// }
// else {
this.express.use(cors({
origin: process.env.FRONTEND_URL,
origin: 'http://localhost:3000',
credentials: true,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
optionsSuccessStatus: 200
}));
}
else {
this.express.use(cors({
origin: 'https://localhost:3000',
credentials: true,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
optionsSuccessStatus: 200
}));
}
// }
this.express.use(function (req: any, res: any, next) {
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-Origin', req.headers.origin);
Expand Down Expand Up @@ -84,7 +84,7 @@ class Application {
resave: false,
saveUninitialized: false,
cookie: {
maxAge: 60 * 60 * 24,
maxAge: 60 * 60 * 24 * 30,
domain: process.env.NODE_ENV === 'production' ? process.env.COOKIE_PUBLIC_DOMAIN : 'localhost',
},
}));
Expand Down
Loading

0 comments on commit 4720e7b

Please sign in to comment.