Skip to content

Commit bed7efa

Browse files
Merge pull request #97 from jd-apprentice/development
Development
2 parents d844fb3 + ed51710 commit bed7efa

File tree

10 files changed

+31
-22
lines changed

10 files changed

+31
-22
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { loadDatabase } from "../../../../src/app/db";
22
import { Config } from "../../../../src/app/config/config";
33
import { app } from "../../../../src/app/main";
44
import { jest, describe, test, beforeAll, expect, beforeEach } from "bun:test";
5-
6-
import request from "supertest";
7-
import { Response } from "supertest";
5+
import request, { Response } from "supertest";
86

97
const baseRoute = "/v1/api/images";
108
const contentTypeKey = "Content-Type";

docker/ARM64.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ COPY --from=install /temp/dev/node_modules node_modules
1515
COPY . .
1616

1717
ENV NODE_ENV=test
18-
RUN bun run lint
19-
RUN bun run build:arm
18+
RUN bun run lint && \
19+
bun run build:arm
2020

2121
FROM base AS release
2222
COPY --from=install /temp/prod/node_modules node_modules

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ COPY --from=install /temp/dev/node_modules node_modules
1515
COPY . .
1616

1717
ENV NODE_ENV=production
18-
RUN bun run lint
19-
RUN bun run build
18+
RUN bun run lint && \
19+
bun run build
2020

2121
FROM base AS release
2222
COPY --from=install /temp/prod/node_modules node_modules

docker/compose.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ services:
55
security_opt:
66
- seccomp:seccomp.json
77
- apparmor:non-root-profile
8-
- no-new-privileges:true
8+
- no-new-privileges
99
build:
10-
context: ../
11-
dockerfile: docker/Dockerfile
10+
context: ../
11+
dockerfile: docker/Dockerfile
1212
## https://dockerlabs.collabnix.com/advanced/security/capabilities/
13-
cap_add: ["DAC_OVERRIDE"]
14-
cap_drop: ["ALL"]
13+
cap_add: [ "DAC_OVERRIDE" ]
14+
cap_drop: [ "ALL" ]
1515
restart: always
1616
env_file:
1717
- ../.env
@@ -21,5 +21,5 @@ services:
2121
- waifuland
2222

2323
networks:
24-
waifuland:
25-
driver: bridge
24+
waifuland:
25+
driver: bridge

kubernetes/prod/020-waifuland-prod-deployment.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,17 @@ spec:
6363
key: TOKEN
6464
name: env
6565
image: dyallo/waifuland_api:X64_latest
66+
resources:
67+
limits:
68+
cpu: 0.5
69+
memory: 512Mi
70+
requests:
71+
cpu: 0.5
72+
memory: 512Mi
73+
ephemeral-storage: "1Gi"
6674
name: waifuland-prod
6775
ports:
6876
- containerPort: 4000
6977
protocol: TCP
70-
restartPolicy: Always
78+
restartPolicy: Always
79+
automountServiceAccountToken: false

src/common/utils/clear.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const clearTemporaryFiles = (filepath: PathLike): void => {
1717
unlink(resolvedPath, (err: unknown) => {
1818
if (err) {
1919
console.error("Failed to delete file: %s", resolvedPath, err);
20-
return;
2120
}
2221
});
2322
};

src/image/image-service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class ImageService {
5555
*/
5656
async upload(newImage: IImage): Promise<IImage> {
5757
try {
58-
return imageRepository.create(newImage);
58+
const response = await imageRepository.create(newImage);
59+
return response;
5960
} catch (error: unknown) {
6061
rollbar.error(error as LogArgument);
6162
throw new Error((<Error>error).message);

src/tag/tag-service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class TagService {
1414
*/
1515
async getTag(): Promise<ITag[]> {
1616
try {
17-
return tagRepository.findTags();
17+
const tags = await tagRepository.findTags();
18+
return tags;
1819
} catch (error: unknown) {
1920
rollbar.error(error as LogArgument);
2021
throw new Error((<Error>error).message);
@@ -28,7 +29,8 @@ class TagService {
2829
*/
2930
async getTagById(id: string): Promise<FindCursor | null> {
3031
try {
31-
return tagRepository.findByTagId(id);
32+
const tag = await tagRepository.findByTagId(id);
33+
return tag;
3234
} catch (error: unknown) {
3335
rollbar.error(error as LogArgument);
3436
throw new Error((<Error>error).message);

src/user/user-middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const userExists = async (
2020
next: NextFunction,
2121
): Promise<Boom | NextFunction | Response | unknown> => {
2222
const { username }: UsernameType = req.body;
23-
const user: UsernameType | null = await User.findOne({ username: { $eq: username } });
23+
const user: UsernameType | null = await User.findOne({
24+
username: { $eq: username },
25+
});
2426
return user ? res.json(boom.conflict('User already exists')) : next();
2527
};
2628

src/user/user-routes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { limiter } from 'src/common/utils/limiter';
99

1010
const userRouter = Router();
1111

12-
13-
1412
userRouter.get('/', limiter, validateToken, userController.getUsers);
1513
userRouter.get('/info', limiter, validateToken, userController.getUserInfo);
1614
userRouter.post('/login', limiter, validateUser, userController.login);

0 commit comments

Comments
 (0)