Skip to content
Snippets Groups Projects
Commit be91d529 authored by Bernard Roland (Student Com20)'s avatar Bernard Roland (Student Com20)
Browse files

Added the possibility to add custom headers

parent 9561ee3d
No related branches found
No related tags found
No related merge requests found
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";
......
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();
}
......@@ -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}`);
});
// Setup the testing environment right here
import '@testing-library/jest-dom';
......@@ -2,7 +2,6 @@
import express from 'express';
import database from '../database';
import { isOfType } from '../util';
import { requireVerification } from './auth';
const user = express();
......
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment