Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions __tests__/image/__tests__/integration/images.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { loadDatabase } from "../../../../src/app/db";
import { Config } from "../../../../src/app/config/config";
import { app } from "../../../../src/app/main";
import { jest, describe, test, beforeAll, expect, beforeEach } from "bun:test";

import request from "supertest";
import { Response } from "supertest";
import request, { Response } from "supertest";

const baseRoute = "/v1/api/images";
const contentTypeKey = "Content-Type";
Expand Down
4 changes: 2 additions & 2 deletions docker/ARM64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ COPY --from=install /temp/dev/node_modules node_modules
COPY . .

ENV NODE_ENV=test
RUN bun run lint
RUN bun run build:arm
RUN bun run lint && \
bun run build:arm

FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ COPY --from=install /temp/dev/node_modules node_modules
COPY . .

ENV NODE_ENV=production
RUN bun run lint
RUN bun run build
RUN bun run lint && \
bun run build

FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
Expand Down
14 changes: 7 additions & 7 deletions docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ services:
security_opt:
- seccomp:seccomp.json
- apparmor:non-root-profile
- no-new-privileges:true
- no-new-privileges
build:
context: ../
dockerfile: docker/Dockerfile
context: ../
dockerfile: docker/Dockerfile
## https://dockerlabs.collabnix.com/advanced/security/capabilities/
cap_add: ["DAC_OVERRIDE"]
cap_drop: ["ALL"]
cap_add: [ "DAC_OVERRIDE" ]
cap_drop: [ "ALL" ]
restart: always
env_file:
- ../.env
Expand All @@ -21,5 +21,5 @@ services:
- waifuland

networks:
waifuland:
driver: bridge
waifuland:
driver: bridge
11 changes: 10 additions & 1 deletion kubernetes/prod/020-waifuland-prod-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ spec:
key: TOKEN
name: env
image: dyallo/waifuland_api:X64_latest
resources:
limits:
cpu: 0.5
memory: 512Mi
requests:
cpu: 0.5
memory: 512Mi
ephemeral-storage: "1Gi"
name: waifuland-prod
ports:
- containerPort: 4000
protocol: TCP
restartPolicy: Always
restartPolicy: Always
automountServiceAccountToken: false
1 change: 0 additions & 1 deletion src/common/utils/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const clearTemporaryFiles = (filepath: PathLike): void => {
unlink(resolvedPath, (err: unknown) => {
if (err) {
console.error("Failed to delete file: %s", resolvedPath, err);
return;
}
});
};
Expand Down
3 changes: 2 additions & 1 deletion src/image/image-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class ImageService {
*/
async upload(newImage: IImage): Promise<IImage> {
try {
return imageRepository.create(newImage);
const response = await imageRepository.create(newImage);
return response;
} catch (error: unknown) {
rollbar.error(error as LogArgument);
throw new Error((<Error>error).message);
Expand Down
6 changes: 4 additions & 2 deletions src/tag/tag-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class TagService {
*/
async getTag(): Promise<ITag[]> {
try {
return tagRepository.findTags();
const tags = await tagRepository.findTags();
return tags;
} catch (error: unknown) {
rollbar.error(error as LogArgument);
throw new Error((<Error>error).message);
Expand All @@ -28,7 +29,8 @@ class TagService {
*/
async getTagById(id: string): Promise<FindCursor | null> {
try {
return tagRepository.findByTagId(id);
const tag = await tagRepository.findByTagId(id);
return tag;
} catch (error: unknown) {
rollbar.error(error as LogArgument);
throw new Error((<Error>error).message);
Expand Down
4 changes: 3 additions & 1 deletion src/user/user-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const userExists = async (
next: NextFunction,
): Promise<Boom | NextFunction | Response | unknown> => {
const { username }: UsernameType = req.body;
const user: UsernameType | null = await User.findOne({ username: { $eq: username } });
const user: UsernameType | null = await User.findOne({
username: { $eq: username },
});
return user ? res.json(boom.conflict('User already exists')) : next();
};

Expand Down
2 changes: 0 additions & 2 deletions src/user/user-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { limiter } from 'src/common/utils/limiter';

const userRouter = Router();



userRouter.get('/', limiter, validateToken, userController.getUsers);
userRouter.get('/info', limiter, validateToken, userController.getUserInfo);
userRouter.post('/login', limiter, validateUser, userController.login);
Expand Down