Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/db-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const knex = require('knex');

const config = require('../knexfile.js');

module.exports = knex(config.development);
18 changes: 18 additions & 0 deletions api/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const express = require('express');
const server = express();
const helmet = require('helmet')
const projectsRouter = require('../routes/projects/projectsRouter');
const resourcesRouter = require('../routes/resources/resourcesRouter');
const tasksRouter = require('../routes/tasks/tasksRouter')

server.use(helmet());
server.use(express.json());
server.use(('/projects/'), projectsRouter);
server.use('/resources/', resourcesRouter);
server.use('/tasks/', tasksRouter);

server.get('/', (req, res) => {
res.json({it:'its up'})
});

module.exports = server;
Binary file added dev.sqlite3
Binary file not shown.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const port = 5750
const server = require('./api/server')

server.listen(port, () => console.log(`***\n The server is running on port ${port}***\n`))
45 changes: 45 additions & 0 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Update with your config settings.

module.exports = {

development: {
client: 'sqlite3',
useNullAsDefault: true,
connection: {
filename: './dev.sqlite3'
}
},

staging: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
},

production: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
}

};
36 changes: 36 additions & 0 deletions migrations/20190917170044_projects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

exports.up = function(knex) {
return knex.schema
.createTable('projects', tbl => {
tbl.increments();
tbl.text('projectsName', 256)
.notNullable()
// .onUpdate('CASCADE');
})

// .createTable('actions', tbl => {
// tbl.increments();
// tbl.text('actionsName', 256)
// .notNullable()
// })
.createTable('tasks', tbl => {
tbl.increments();
tbl.text('tasksName', 256)
.notNullable()

})
.createTable('resources', tbl => {
tbl.increments();
tbl.text('resourcesName', 256)
.notNullable()

})
};

exports.down = function(knex) {
return knex.schema
.dropTableIfExists('projects')
// .dropTableIfExists('actions')
.dropTableIfExists('tasks')
.dropTableIfExists('resources');
};
Loading