Skip to content

Commit 6feda9f

Browse files
committed
Temporal commit 1
1 parent 8640d77 commit 6feda9f

17 files changed

Lines changed: 212 additions & 2 deletions

‎back/.babelrc‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,17 @@
1313
}
1414
]
1515
],
16-
"plugins": ["@babel/plugin-proposal-optional-chaining"]
16+
"plugins": ["@babel/plugin-proposal-optional-chaining",
17+
[
18+
"module-resolver",
19+
{
20+
"root": ["."],
21+
"alias": {
22+
"core": "./src/core",
23+
"dals": "./src/dals",
24+
"pods": "./src/pods"
25+
}
26+
}
27+
]
28+
]
1729
}

‎back/docker-compose.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3'
2+
services:
3+
mongodb-codepaster:
4+
container_name: mongodb-codepaster
5+
image: mongo:4.2.10
6+
ports:
7+
- '27017:27017'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const envConstants = {
2+
NODE_ENV: process.env.NODE_ENV,
3+
PORT: process.env.PORT,
4+
SOCKET_PORT: process.env.SOCKET_PORT,
5+
isMockRepository: process.env.MOCK_RESPOSITORY === 'true',
6+
MONGODB_URI: process.env.MONGODB_URI,
7+
API_URL: process.env.API_URL,
8+
CORS_ORIGIN: process.env.CORS_ORIGIN,
9+
};
10+

‎back/src/core/constants/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './env.constants';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { connect } from 'mongoose';
2+
3+
export const connectToDB = async (connectionString: string) => {
4+
const db = await connect(connectionString, {
5+
poolSize: 5,
6+
useNewUrlParser: true,
7+
promiseLibrary: Promise,
8+
useUnifiedTopology: true,
9+
useFindAndModify: false,
10+
});
11+
12+
console.log('Connected to DB');
13+
14+
return db;
15+
};

‎back/src/core/servers/cors.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { envConstants } from '../constants';
2+
import cors from 'cors';
3+
4+
const options: cors.CorsOptions = {
5+
allowedHeaders: [
6+
'Origin',
7+
'X-Requested-With',
8+
'Content-Type',
9+
'Accept',
10+
'X-Access-Token',
11+
],
12+
credentials: true,
13+
methods: 'GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE',
14+
// IMPORTANT LIMIT HERE YOUR CLIENT APPS DOMAINS
15+
origin: envConstants.CORS_ORIGIN,
16+
preflightContinue: false,
17+
};
18+
19+
export const corsOptions = cors(options);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import express from 'express';
2+
import bodyParser from 'body-parser';
3+
import { corsOptions } from './cors'
4+
5+
export const createApp = () => {
6+
const app = express();
7+
8+
app.use(bodyParser.urlencoded({ extended: false }));
9+
app.use(bodyParser.json());
10+
app.use(corsOptions);
11+
return app;
12+
};

‎back/src/core/servers/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './express.server';
2+
3+
//TODO: refactoring
4+
//export * from './sockets.server';

‎back/src/dals/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './room';
2+
export * from './session';

‎back/src/dals/room/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './room.model';

0 commit comments

Comments
 (0)