diff --git a/server/src/config.ts b/server/src/config.ts index f083c089ce18dd158ee2c642be4f1336b1696439..0c932c1b3ddc51dc7f44f0167389c7c9811db27c 100644 --- a/server/src/config.ts +++ b/server/src/config.ts @@ -1,9 +1,13 @@ -export const port = "development"; +export const port = 8000; export const keys = { private: '/etc/ssl/localcerts/cert.key', - public: '/etc/ssl/localcerts/cert.pem' + public: '/etc/ssl/localcerts/cert.pem', +}; + +export const headers = { + 'Access-Control-Allow-Origin': '*', }; export const environment = "development"; diff --git a/server/src/headers.ts b/server/src/headers.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1ff6b96474559384bcb89c388fc0b7d09e23b2f --- /dev/null +++ b/server/src/headers.ts @@ -0,0 +1,13 @@ + +import { NextFunction, Request, Response } from 'express'; + +import { headers } from './config'; + +export function addDefaultHeaders(_req: Request, res: Response, next: NextFunction) { + let header : keyof typeof headers; + for (header in headers) { + res.header(header, headers[header]); + } + next(); +} + diff --git a/server/src/index.ts b/server/src/index.ts index 4c8a0dd0110e1197802d6b80eddc510e5a36b042..9b13dd2973e9760c51f6904d33de699a8582a4a1 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -2,11 +2,13 @@ import express, { Request, Response, NextFunction } from 'express'; import { json as bodyJson } from 'body-parser'; +import { port } from './config'; +import { addDefaultHeaders } from './headers'; import v1 from './v1'; const app = express(); -const PORT = 8000; +app.use(addDefaultHeaders); app.use(bodyJson()); app.use('/v1', v1); @@ -25,7 +27,7 @@ app.use((_err: Error, _req: Request, res: Response, _next: NextFunction) => { }); }); -app.listen(PORT, () => { - console.log(`[server] Server is running at https://localhost:${PORT}`); +app.listen(port, () => { + console.log(`[server] Server is running at https://localhost:${port}`); }); diff --git a/server/src/setupTests.ts b/server/src/setupTests.ts index 0662879834d84c5f81ffbe250a3b1c581c2b1e8b..7ce45c2931a9e112706ab9fb55c01cc8580b0ff1 100644 --- a/server/src/setupTests.ts +++ b/server/src/setupTests.ts @@ -1,3 +1,3 @@ -// Setup the testing environment right here +import '@testing-library/jest-dom'; diff --git a/server/src/v1/user.ts b/server/src/v1/user.ts index 51373ad94cd3a73b7c9293d5747b5ca83acf4ef1..f23b5b8cdf7a93de07b2bf6b98af8b65370e18ce 100644 --- a/server/src/v1/user.ts +++ b/server/src/v1/user.ts @@ -2,7 +2,6 @@ import express from 'express'; import database from '../database'; -import { isOfType } from '../util'; import { requireVerification } from './auth'; const user = express(); diff --git a/server/tsconfig.json b/server/tsconfig.json index 5802e663b6adcd7789108501239f918b7750bc73..340c6162587908c9907869734f74cfc91f5d6e1a 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -3,6 +3,15 @@ "target": "es6", "lib": [ ], + "allowJs": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, "module": "commonjs", "rootDir": "src", "outDir": "build",