Skip to content

Commit 1961f3c

Browse files
committed
Add build script
1 parent eabdce9 commit 1961f3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+548
-114
lines changed

backend/code-execution-service/Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-alpine
1+
FROM node:20-alpine AS base
22

33
WORKDIR /code-execution-service
44

@@ -10,4 +10,16 @@ COPY . .
1010

1111
EXPOSE 3004
1212

13+
# DEV
14+
15+
FROM base AS dev
16+
1317
CMD ["npm", "run", "dev"]
18+
19+
# PROD
20+
21+
FROM base AS prod
22+
23+
RUN npm run build
24+
25+
CMD ["npm", "start"]

backend/code-execution-service/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"main": "server.ts",
55
"type": "module",
66
"scripts": {
7-
"start": "tsx server.ts",
8-
"dev": "tsx watch server.ts",
7+
"start": "tsx dist/server.js",
8+
"dev": "tsx watch src/server.ts",
9+
"build": "tsc",
910
"test": "cross-env NODE_ENV=test && jest",
1011
"test:watch": "cross-env NODE_ENV=test && jest --watch",
1112
"lint": "eslint ."

backend/code-execution-service/app.ts renamed to backend/code-execution-service/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import yaml from "yaml";
55
import swaggerUi from "swagger-ui-express";
66
import cors from "cors";
77

8-
import codeExecutionRoutes from "./src/routes/codeExecutionRoutes.ts";
8+
import codeExecutionRoutes from "./routes/codeExecutionRoutes";
99

1010
dotenv.config();
1111

File renamed without changes.

backend/code-execution-service/tsconfig.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

1313
/* Language and Environment */
14-
"target": "ES2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
14+
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
1515
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
1616
// "jsx": "preserve", /* Specify what JSX code is generated. */
1717
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
@@ -26,7 +26,7 @@
2626

2727
/* Modules */
2828
"module": "ESNext" /* Specify what module code is generated. */,
29-
// "rootDir": "./", /* Specify the root folder within your source files. */
29+
"rootDir": "./src" /* Specify the root folder within your source files. */,
3030
"moduleResolution": "Node" /* Specify how TypeScript looks up a file from a given module specifier. */,
3131
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
3232
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
@@ -35,7 +35,7 @@
3535
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
3636
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
3737
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38-
"allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
38+
// "allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
3939
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
4040
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
4141
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
@@ -55,9 +55,9 @@
5555
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5656
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5757
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
58-
"noEmit": true /* Disable emitting files from a compilation. */,
58+
// "noEmit": true, /* Disable emitting files from a compilation. */
5959
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
60-
// "outDir": "./", /* Specify an output folder for all emitted files. */
60+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
6161
// "removeComments": true, /* Disable emitting comments. */
6262
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6363
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
@@ -106,5 +106,7 @@
106106
/* Completeness */
107107
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108108
"skipLibCheck": true /* Skip type checking all .d.ts files. */
109-
}
109+
},
110+
"include": ["src/**/*"],
111+
"exclude": ["node_modules", "dist"]
110112
}

backend/collab-service/Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-alpine
1+
FROM node:20-alpine AS base
22

33
WORKDIR /collab-service
44

@@ -10,4 +10,16 @@ COPY . .
1010

1111
EXPOSE 3003
1212

13+
# DEV
14+
15+
FROM base AS dev
16+
1317
CMD ["npm", "run", "dev"]
18+
19+
# PROD
20+
21+
FROM base AS prod
22+
23+
RUN npm run build
24+
25+
CMD ["npm", "start"]

backend/collab-service/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"main": "server.ts",
55
"type": "module",
66
"scripts": {
7-
"start": "tsx src/server.ts",
7+
"start": "tsx src/server.js",
88
"dev": "tsx watch src/server.ts",
9+
"build": "tsc",
910
"test": "cross-env NODE_ENV=test && jest",
1011
"test:watch": "cross-env NODE_ENV=test && jest --watch",
1112
"lint": "eslint ."

backend/collab-service/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import yaml from "yaml";
55
import swaggerUi from "swagger-ui-express";
66
import cors from "cors";
77

8-
import collabRoutes from "./routes/collabRoutes.ts";
8+
import collabRoutes from "./routes/collabRoutes";
99

1010
dotenv.config();
1111

backend/collab-service/src/middlewares/basicAccessControl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ExtendedError, Socket } from "socket.io";
2-
import { verifyToken } from "../api/userService.ts";
2+
import { verifyToken } from "../api/userService";
33

44
export const verifyUserToken = (
55
socket: Socket,

backend/collab-service/src/server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import http from "http";
2-
import app, { allowedOrigins } from "./app.ts";
3-
import { handleWebsocketCollabEvents } from "./handlers/websocketHandler.ts";
2+
import app, { allowedOrigins } from "./app";
3+
import { handleWebsocketCollabEvents } from "./handlers/websocketHandler";
44
import { Server, Socket } from "socket.io";
5-
import { connectRedis } from "./config/redis.ts";
6-
import { verifyUserToken } from "./middlewares/basicAccessControl.ts";
5+
import { connectRedis } from "./config/redis";
6+
import { verifyUserToken } from "./middlewares/basicAccessControl";
77

88
const server = http.createServer(app);
99

0 commit comments

Comments
 (0)