Controller framework working
This commit is contained in:
0
scripts/install.sh
Normal file
0
scripts/install.sh
Normal file
17
scripts/users.sql
Normal file
17
scripts/users.sql
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
CREATE TABLE `notes`.`Users` (
|
||||||
|
`id` bigint(20) NOT NULL,
|
||||||
|
`username` text,
|
||||||
|
`password` text,
|
||||||
|
`email` text,
|
||||||
|
`phone` text,
|
||||||
|
`ip` text, `
|
||||||
|
token` text,
|
||||||
|
`lastupdated` text,
|
||||||
|
`verified` tinyint(4) NOT NULL DEFAULT '0',
|
||||||
|
`authcode` text,
|
||||||
|
`timeauthed` text NOT NULL,
|
||||||
|
`admin` tinyint(4) DEFAULT NULL
|
||||||
|
)
|
||||||
|
|
||||||
|
ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
|
ALTER TABLE `notes`.`Users` ADD PRIMARY KEY (`id`);
|
||||||
3
src/controllers/controllerHandler.js
Normal file
3
src/controllers/controllerHandler.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export class ControllerHandler {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,3 @@
|
|||||||
import {Logger} from '../models/logger';
|
export let Controllers = {};
|
||||||
|
|
||||||
module.exports.Controller
|
Controllers.UserController = require('./user').UserController;
|
||||||
|
|
||||||
Controller.UserController = () => {}
|
|
||||||
|
|
||||||
|
|
||||||
class ControllerHandler {}
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {Logger} from '../../models/logger';
|
|||||||
import {Server} from '../../server';
|
import {Server} from '../../server';
|
||||||
import {MiddleWare} from '../middleware';
|
import {MiddleWare} from '../middleware';
|
||||||
import {StatusCodes} from '../status';
|
import {StatusCodes} from '../status';
|
||||||
|
import {Controllers} from '../index';
|
||||||
|
|
||||||
let app;
|
let app;
|
||||||
|
|
||||||
@@ -12,9 +13,9 @@ export class Router {
|
|||||||
app = Server.App;
|
app = Server.App;
|
||||||
app.get('/', [MiddleWare.analytics, Router.frontPage]);
|
app.get('/', [MiddleWare.analytics, Router.frontPage]);
|
||||||
|
|
||||||
app.get('/user/:id', (req, res) => [MiddleWare.analytics, Controllers.getUser]);
|
app.get('/user/:id', (req, res) => [MiddleWare.analytics]);
|
||||||
app.delete('/user/:id', (req, res) => {});
|
app.delete('/user/:id', (req, res) => {});
|
||||||
app.post('/user', (req, res) => {});
|
app.post('/user', [MiddleWare.analytics, Controllers.UserController.newUser]);
|
||||||
|
|
||||||
app.use([MiddleWare.analytics, StatusCodes.pageNotFound]);
|
app.use([MiddleWare.analytics, StatusCodes.pageNotFound]);
|
||||||
Logger.info('HTTP endpoints settup');
|
Logger.info('HTTP endpoints settup');
|
||||||
|
|||||||
9
src/controllers/user.js
Normal file
9
src/controllers/user.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import {Logger} from '../models/logger';
|
||||||
|
import {ControllerHandler} from './controllerHandler';
|
||||||
|
|
||||||
|
export class UserController extends ControllerHandler {
|
||||||
|
static newUser(req, res, next) {
|
||||||
|
Logger.info('NEW USER');
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user