Skip to content

Commit d844fb3

Browse files
Merge pull request #95 from jd-apprentice/development
Update PROD
2 parents a0a83d8 + 006db63 commit d844fb3

16 files changed

Lines changed: 39 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ jobs:
5454
bun install
5555
bun test
5656
57-
codacy:
58-
uses: jd-apprentice/jd-workflows/.github/workflows/codacy.yml@main
59-
needs: [gitleaks, test]
60-
with:
61-
name: Codacy
62-
secrets:
63-
project_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
64-
6557
dev:
6658
runs-on: ubuntu-latest
6759
needs: [gitleaks, test]

__tests__/app/__tests__/main.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ describe('INTEGRATION - App Module', () => {
1818
})
1919
});
2020

21-
test('GET /api - when asking for the api route should return 200 and api message', async () => {
21+
test('GET /v1/api - when asking for the api route should return 200 and api message', async () => {
2222
await request(app)
23-
.get('/api')
23+
.get('/v1/api')
2424
.expect(contentTypeKey, contentTypeValue)
2525
.expect(httpSuccess)
2626
.then((response) => {

__tests__/image/__tests__/integration/images.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { jest, describe, test, beforeAll, expect, beforeEach } from "bun:test";
66
import request from "supertest";
77
import { Response } from "supertest";
88

9-
const baseRoute = "/api/images";
9+
const baseRoute = "/v1/api/images";
1010
const contentTypeKey = "Content-Type";
1111
const contentTypeValue = /json/;
1212
const httpSuccess = 200;

__tests__/tag/__tests__/tags.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { describe, test, expect, beforeAll, jest, beforeEach } from 'bun:test';
88
const contentTypeKey = 'Content-Type';
99
const contentTypeValue = /json/;
1010
const httpSuccess = 200;
11-
const baseRoute = "/api/tags";
11+
const baseRoute = "/v1/api/tags";
1212

1313
const tagResponse = {
1414
_id: expect.any(String),

__tests__/user/__tests__/users.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const contentTypeKey = 'Content-Type';
1010
const contentTypeValue = /json/;
1111
const httpSuccess = 200;
1212
const httpUnauthorized = 401;
13-
const baseRoute = "/api/user";
13+
const baseRoute = "/v1/api/user";
1414

1515
const userResponse = {
1616
_id: expect.any(String),

bun.lockb

433 Bytes
Binary file not shown.

src/app/constants/cors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const allowedOrigins = ['https://waifuland.jonathan.com.ar', 'https://waifus.jonathan.com.ar'];
2+
export const corsConfiguration = {
3+
origin: allowedOrigins,
4+
methods: ['GET', 'POST', 'PUT'],
5+
allowedHeaders: ['Content-Type', 'Authorization'],
6+
credentials: true,
7+
maxAge: 3600
8+
}

src/app/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import cors from 'cors';
55

66
// Internal Modules
77
import { routes } from './routes/index';
8+
import { corsConfiguration } from './constants/cors';
89

910
// Express
1011
const app = express();
1112
app.use(express.json());
1213
app.use(express.urlencoded({ extended: false }));
13-
app.use(cors());
14+
app.use(cors(corsConfiguration));
1415
app.use(helmet());
15-
app.use('/api', routes);
16+
app.use('/v1/api', routes);
1617
app.use('/', (req, res) =>
1718
res.status(200).json({ message: 'Allo! Catch-all route.' }),
1819
);

src/common/utils/limiter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import rateLimit from 'express-rate-limit';
2+
3+
export const limiter = rateLimit({
4+
windowMs: 15 * 60 * 1000,
5+
max: 100,
6+
message: 'Too many requests from this IP, please try again after 15 minutes',
7+
});

src/image/image-repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ImageRepository {
1111
* @return { Promise<IImage> } - A new image created
1212
*/
1313
async create(image: IImage): Promise<IImage> {
14-
const tagExists = await Tag.findOne({ tag_id: image.tag.tag_id });
14+
const tagExists = await Tag.findOne({ tag_id: { $eq: image.tag } });
1515
const _idTag = tagExists?._id;
1616
return Image.create({
1717
...image,

0 commit comments

Comments
 (0)