mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/node-tutorial.git
synced 2026-08-19 04:24:10 +00:00
init
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const logger = require('morgan');
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
app.use(logger('dev'));
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
app.use(bodyParser.urlencoded({ extended: false }));
|
||||||
|
|
||||||
|
// Require our routes into the application.
|
||||||
|
require('./server/routes')(app);
|
||||||
|
app.get('*', (req, res) => res.status(200).send({
|
||||||
|
message: 'Welcome to the beginning of nothingness.',
|
||||||
|
}));
|
||||||
|
|
||||||
|
module.exports = app;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// This will be our application entry. We'll setup our server here.
|
||||||
|
const http = require('http');
|
||||||
|
const app = require('../app'); // The express app we just created
|
||||||
|
|
||||||
|
const port = parseInt(process.env.PORT, 10) || 8000;
|
||||||
|
app.set('port', port);
|
||||||
|
|
||||||
|
const server = http.createServer(app);
|
||||||
|
server.listen(port);
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
server:
|
||||||
|
image: node:7
|
||||||
|
command: npm run start:dev
|
||||||
|
working_dir: /app
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
environment:
|
||||||
|
PORT: 3000
|
||||||
|
CONNECTION_STRING_DEV: postgres://user:password@db/db
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
- "5858:5858"
|
||||||
|
links:
|
||||||
|
- db
|
||||||
|
db:
|
||||||
|
image: postgres
|
||||||
|
expose:
|
||||||
|
- 5432
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
POSTGRES_USER: user
|
||||||
|
POSTGRES_DB: db
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "node-totorial",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start:dev": "nodemon ./bin/www",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"db:migrate": "./node_modules/.bin/sequelize db:migrate",
|
||||||
|
"db:seed": "db:seed:all"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"body-parser": "^1.18.2",
|
||||||
|
"express": "^4.16.3",
|
||||||
|
"morgan": "^1.9.0",
|
||||||
|
"pg": "^7.4.1",
|
||||||
|
"pg-hstore": "^2.3.2",
|
||||||
|
"sequelize": "^4.37.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^1.17.2",
|
||||||
|
"sequelize-cli": "^2.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"development": {
|
||||||
|
"username": "user",
|
||||||
|
"password": "password",
|
||||||
|
"database": "db",
|
||||||
|
"host": "db",
|
||||||
|
"port": 5432,
|
||||||
|
"dialect": "postgres"
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"username": "root",
|
||||||
|
"password": null,
|
||||||
|
"database": "database_test",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 5432,
|
||||||
|
"dialect": "postgres"
|
||||||
|
},
|
||||||
|
"production": {
|
||||||
|
"username": "root",
|
||||||
|
"password": null,
|
||||||
|
"database": "database_production",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"dialect": "mysql"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = (app) => {
|
||||||
|
app.get('/api', (req, res) => res.status(200).send({
|
||||||
|
message: 'Welcome to the Todos API!',
|
||||||
|
}));
|
||||||
|
};
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
docker exec -it $(docker ps | grep server | awk '{ print $1 }') /bin/sh -c 'npm run db:migrate'
|
||||||
|
docker exec -it $(docker ps | grep server | awk '{ print $1 }') /bin/sh -c 'npm run db:seed'
|
||||||
|
docker kill $(docker ps | grep server | awk '{ print $1 }')
|
||||||
|
docker kill $(docker ps | grep db | awk '{ print $1 }')
|
||||||
|
docker-compose up
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
docker exec -it $(docker ps | grep server | awk '{ print $1 }') /bin/sh -c 'npm run db:migrate'
|
||||||
|
docker exec -it $(docker ps | grep server | awk '{ print $1 }') /bin/sh -c 'npm run db:seed'
|
||||||
|
docker kill $(docker ps | grep server | awk '{ print $1 }')
|
||||||
|
docker kill $(docker ps | grep db | awk '{ print $1 }')
|
||||||
|
docker-compose up
|
||||||
Reference in New Issue
Block a user