Replace bcrypt with bcryptjs / move env to config
This commit is contained in:
parent
bf2fb47033
commit
fce5a162d3
@ -1,7 +1,8 @@
|
|||||||
|
require('dotenv').config();
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
const helmet = require('helmet');
|
const helmet = require('helmet');
|
||||||
require('dotenv').config();
|
|
||||||
|
|
||||||
const accountsRoute = require('./routes/accountRoute');
|
const accountsRoute = require('./routes/accountRoute');
|
||||||
const meetingsRoute = require('./routes/meetingRoute');
|
const meetingsRoute = require('./routes/meetingRoute');
|
||||||
@ -15,6 +16,13 @@ server.use(cors());
|
|||||||
server.use(express.json());
|
server.use(express.json());
|
||||||
server.use(helmet());
|
server.use(helmet());
|
||||||
|
|
||||||
|
server.use(bodyParser.json());
|
||||||
|
server.use(
|
||||||
|
bodyParser.urlencoded({
|
||||||
|
extended: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
server.use('/api/accounts', accountsRoute);
|
server.use('/api/accounts', accountsRoute);
|
||||||
server.use('/api/meetings', meetingsRoute);
|
server.use('/api/meetings', meetingsRoute);
|
||||||
server.use('/api/participants', participantsRoute);
|
server.use('/api/participants', participantsRoute);
|
||||||
|
6
config/config.js
Normal file
6
config/config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
jwt_secret: process.env.JWT_SECRET,
|
||||||
|
port: process.env.PORT || 3001,
|
||||||
|
db_url: process.env.DATABASE_URL,
|
||||||
|
environment: process.env.NODE_ENV,
|
||||||
|
};
|
@ -1,8 +1,8 @@
|
|||||||
const knex = require('knex');
|
const knex = require('knex');
|
||||||
|
|
||||||
const knexfile = require('../knexfile');
|
const knexfile = require('../knexfile');
|
||||||
|
const { environment} = require('../config/config')
|
||||||
|
|
||||||
const env = process.env.NODE_ENV || 'development';
|
const env = environment || 'development';
|
||||||
const configOptions = knexfile[env];
|
const configOptions = knexfile[env];
|
||||||
|
|
||||||
module.exports = knex(configOptions);
|
module.exports = knex(configOptions);
|
||||||
|
7
index.js
7
index.js
@ -1,9 +1,8 @@
|
|||||||
const server = require('./api/server.js');
|
const server = require('./api/server.js');
|
||||||
|
const { port } = require('./config/config');
|
||||||
|
|
||||||
const PORT = process.env.PORT || 3001;
|
server.listen(port, () =>
|
||||||
|
|
||||||
server.listen(PORT, () =>
|
|
||||||
console.log(
|
console.log(
|
||||||
`Meeting Planner Backend listening at http://localhost:${PORT}`,
|
`Meeting Planner Backend listening at http://localhost:${port}`,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
const { db_url } = require('./config/config');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
development: {
|
development: {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: process.env.DATABASE_URL,
|
connection: db_url,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: './data/migrations',
|
directory: './data/migrations',
|
||||||
},
|
},
|
||||||
@ -13,7 +14,7 @@ module.exports = {
|
|||||||
|
|
||||||
testing: {
|
testing: {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: process.env.DATABASE_URL,
|
connection: db_url,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: './data/migrations',
|
directory: './data/migrations',
|
||||||
},
|
},
|
||||||
@ -23,7 +24,7 @@ module.exports = {
|
|||||||
|
|
||||||
production: {
|
production: {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: process.env.DATABASE_URL,
|
connection: db_url,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: './data/migrations',
|
directory: './data/migrations',
|
||||||
},
|
},
|
||||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -113,6 +113,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"bcryptjs": {
|
||||||
|
"version": "2.4.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
|
||||||
|
"integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms="
|
||||||
|
},
|
||||||
"bluebird": {
|
"bluebird": {
|
||||||
"version": "3.7.2",
|
"version": "3.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"author": "rui hildt",
|
"author": "rui hildt",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"bcryptjs": "^2.4.3",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user