mirror of
https://github.com/filiprojek/nork.git
synced 2024-11-23 01:01:04 +01:00
nork works
This commit is contained in:
parent
00033fd439
commit
9c03dbef15
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nork",
|
"name": "nork",
|
||||||
"version": "3.0.1",
|
"version": "3.0.3",
|
||||||
"description": "The best node.js 'framework' :)",
|
"description": "The best node.js 'framework' :)",
|
||||||
"main": "dist/app.js",
|
"main": "dist/app.js",
|
||||||
"bin": "dist/app.js",
|
"bin": "dist/app.js",
|
||||||
@ -9,9 +9,12 @@
|
|||||||
"start": "npm run start:prod",
|
"start": "npm run start:prod",
|
||||||
"start:dev": "ts-node src/app.ts",
|
"start:dev": "ts-node src/app.ts",
|
||||||
"start:prod": "node dist/app.js",
|
"start:prod": "node dist/app.js",
|
||||||
"build": "rimraf dist && tsc -p .",
|
"tsc": "tsc -p .",
|
||||||
|
"clean": "rimraf dist",
|
||||||
|
"copy-assets": "ts-node src/utils/copyAssets",
|
||||||
|
"build": "npm-run-all clean tsc copy-assets",
|
||||||
"test": "mocha --config .mocharc.json --watch src/**/*.test.ts",
|
"test": "mocha --config .mocharc.json --watch src/**/*.test.ts",
|
||||||
"prepublish": "rimraf dist && tsc -p ."
|
"prepublish": "npm-run-all build"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"node",
|
"node",
|
||||||
@ -32,12 +35,15 @@
|
|||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/inquirer": "^8.1.3",
|
"@types/inquirer": "^8.1.3",
|
||||||
"@types/mocha": "^9.0.0",
|
"@types/mocha": "^9.0.0",
|
||||||
|
"@types/shelljs": "^0.8.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
||||||
"@typescript-eslint/parser": "^5.5.0",
|
"@typescript-eslint/parser": "^5.5.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"eslint": "^8.3.0",
|
"eslint": "^8.3.0",
|
||||||
"mocha": "^9.1.3",
|
"mocha": "^9.1.3",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
"shelljs": "^0.8.5",
|
||||||
"ts-node": "^10.4.0",
|
"ts-node": "^10.4.0",
|
||||||
"typescript": "^4.5.2"
|
"typescript": "^4.5.2"
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
/* spell-checker: disable */
|
/* spell-checker: disable */
|
||||||
|
|
||||||
|
# Todo:
|
||||||
|
- [ ] auth jwt refresh token based system
|
||||||
|
- https://auth0.com/blog/refresh-tokens-what-are-they-and-when-to-use-them/
|
||||||
|
- [ ] version of nork control
|
||||||
|
- [ ] upgrade to newer version system
|
||||||
|
|
||||||
|
|
||||||
### 11-24-2021
|
### 11-24-2021
|
||||||
- zacal jsem predelavat nork do OOP
|
- zacal jsem predelavat nork do OOP
|
||||||
- co jsem udelal:
|
- co jsem udelal:
|
||||||
@ -7,7 +14,7 @@
|
|||||||
- [x] --version
|
- [x] --version
|
||||||
- [x] setup
|
- [x] setup
|
||||||
- [x] make
|
- [x] make
|
||||||
- [ ] create
|
- [x] create
|
||||||
- delam na tom
|
- delam na tom
|
||||||
- je treba dopsat par types a fixnout zbytek erroru
|
- je treba dopsat par types a fixnout zbytek erroru
|
||||||
- zatim netestovana funkcnost
|
- zatim netestovana funkcnost
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
import Routes from './routes'
|
import Routes from './routes'
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.app = void 0;
|
|
||||||
const express_1 = __importDefault(require("express"));
|
|
||||||
const morgan_1 = __importDefault(require("morgan"));
|
|
||||||
const path_1 = __importDefault(require("path"));
|
|
||||||
const cors_1 = __importDefault(require("cors"));
|
|
||||||
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
||||||
const routes_1 = require("@/routes");
|
|
||||||
const middlewares_1 = require("@/middlewares");
|
|
||||||
const corsWhitelist = ['http://localhost:8080', 'http://localhost:6060'];
|
|
||||||
const corsOptions = {
|
|
||||||
origin: function (origin, callback) {
|
|
||||||
if (!origin || corsWhitelist.indexOf(origin) !== -1) {
|
|
||||||
callback(null, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
callback(new Error('Not allowed by CORS'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
optionsSuccessStatus: 200,
|
|
||||||
credentials: true,
|
|
||||||
};
|
|
||||||
exports.app = (0, express_1.default)();
|
|
||||||
// Middlewares
|
|
||||||
exports.app.use(middlewares_1.router);
|
|
||||||
exports.app.set('view engine', 'ejs');
|
|
||||||
exports.app.set('views', path_1.default.join(__dirname, 'views'));
|
|
||||||
exports.app.use((0, cors_1.default)(corsOptions));
|
|
||||||
exports.app.use((0, morgan_1.default)('dev'));
|
|
||||||
exports.app.use(express_1.default.urlencoded({ extended: true }));
|
|
||||||
exports.app.use(express_1.default.json());
|
|
||||||
exports.app.use(express_1.default.static(path_1.default.join(__dirname, 'public')));
|
|
||||||
exports.app.use((0, cookie_parser_1.default)());
|
|
||||||
// Routes
|
|
||||||
exports.app.use(routes_1.router);
|
|
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.root_get = void 0;
|
|
||||||
const root_get = (req, res) => {
|
|
||||||
res.render('home');
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
exports.root_get = root_get;
|
|
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.router = void 0;
|
|
||||||
const express_1 = require("express");
|
|
||||||
const sayHiMiddleware_1 = require("@/middlewares/sayHiMiddleware");
|
|
||||||
exports.router = (0, express_1.Router)();
|
|
||||||
exports.router.use(sayHiMiddleware_1.router);
|
|
@ -1,9 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.router = void 0;
|
|
||||||
const express_1 = require("express");
|
|
||||||
exports.router = (0, express_1.Router)();
|
|
||||||
exports.router.use((req, res, next) => {
|
|
||||||
console.log('Hi :)');
|
|
||||||
next();
|
|
||||||
});
|
|
@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.router = void 0;
|
|
||||||
const express_1 = require("express");
|
|
||||||
const rootRoutes_1 = require("./rootRoutes");
|
|
||||||
exports.router = (0, express_1.Router)();
|
|
||||||
exports.router.use(rootRoutes_1.router);
|
|
||||||
// 404
|
|
||||||
exports.router.use((req, res) => {
|
|
||||||
res.status(404).send('E404');
|
|
||||||
});
|
|
@ -1,26 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.router = void 0;
|
|
||||||
const express_1 = require("express");
|
|
||||||
const rootController = __importStar(require("@/controllers/rootController"));
|
|
||||||
exports.router = (0, express_1.Router)();
|
|
||||||
exports.router.get('/', rootController.root_get);
|
|
@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const mongoose_1 = __importDefault(require("mongoose"));
|
|
||||||
const app_1 = require("@/app");
|
|
||||||
const environment_1 = __importDefault(require("@/utils/environment"));
|
|
||||||
const globalService_1 = require("@/services/globalService");
|
|
||||||
const port = environment_1.default.APP_PORT || 8080;
|
|
||||||
// MongoDB
|
|
||||||
const dbURI = environment_1.default.DB_URI;
|
|
||||||
mongoose_1.default
|
|
||||||
.connect(dbURI, {
|
|
||||||
useNewUrlParser: true,
|
|
||||||
useUnifiedTopology: true,
|
|
||||||
useCreateIndex: true,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
new globalService_1.Succ(200, 'connected to db');
|
|
||||||
app_1.app.listen(port, () => {
|
|
||||||
new globalService_1.Succ(200, `Server is listening on http://localhost:${port}`);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
new globalService_1.Err(500, err);
|
|
||||||
});
|
|
@ -1,37 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.Succ = exports.Err = void 0;
|
|
||||||
const colors_1 = __importDefault(require("colors"));
|
|
||||||
class Err {
|
|
||||||
constructor(code, message) {
|
|
||||||
this.code = code;
|
|
||||||
this.message = message;
|
|
||||||
this.drop();
|
|
||||||
}
|
|
||||||
drop() {
|
|
||||||
console.log(colors_1.default.bgRed(`${this.code}`) + colors_1.default.bgBlack.red(` ${this.message}`));
|
|
||||||
return {
|
|
||||||
code: this.code,
|
|
||||||
message: this.message,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Err = Err;
|
|
||||||
class Succ {
|
|
||||||
constructor(code, message) {
|
|
||||||
this.code = code;
|
|
||||||
this.message = message;
|
|
||||||
this.drop();
|
|
||||||
}
|
|
||||||
drop() {
|
|
||||||
console.log(colors_1.default.bgGreen.black(`${this.code}`) + colors_1.default.green.bgBlack(` ${this.message}`));
|
|
||||||
return {
|
|
||||||
code: this.code,
|
|
||||||
message: this.message,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Succ = Succ;
|
|
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.helloWorld = void 0;
|
|
||||||
const helloWorld = () => {
|
|
||||||
console.log('hello world');
|
|
||||||
};
|
|
||||||
exports.helloWorld = helloWorld;
|
|
@ -1,9 +0,0 @@
|
|||||||
const { getReq, getRes } = require('./modules/reqRes.module.js')
|
|
||||||
const { root_get } = require('../controllers/rootController.ts')
|
|
||||||
|
|
||||||
test('Home page render test', () => {
|
|
||||||
const req = getReq()
|
|
||||||
const res = getRes()
|
|
||||||
|
|
||||||
expect(root_get(req, res)).toBe(true)
|
|
||||||
})
|
|
@ -1,16 +0,0 @@
|
|||||||
module.exports.getReq = () => {
|
|
||||||
const req = {}
|
|
||||||
req.body = {}
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.getRes = () => {
|
|
||||||
const res = {}
|
|
||||||
res.locals = {}
|
|
||||||
res.status = () => res
|
|
||||||
res.json = () => res
|
|
||||||
res.send = () => res
|
|
||||||
res.render = () => res
|
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const shell = __importStar(require("shelljs"));
|
|
||||||
// Copy all the view templates
|
|
||||||
shell.cp('-R', 'src/views', 'dist/');
|
|
||||||
shell.cp('-R', 'src/public', 'dist/');
|
|
||||||
shell.cp('-R', 'src/models', 'dist/');
|
|
||||||
shell.cp('-u', 'src/.env', 'dist/');
|
|
@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const path_1 = __importDefault(require("path"));
|
|
||||||
require('dotenv').config({ path: path_1.default.join(__dirname, '../.env') });
|
|
||||||
exports.default = {
|
|
||||||
APP_PORT: Number(process.env.APP_PORT),
|
|
||||||
DB_URI: String(process.env.DB_URI),
|
|
||||||
};
|
|
@ -16,6 +16,8 @@
|
|||||||
"node_modules",
|
"node_modules",
|
||||||
"src/make-files",
|
"src/make-files",
|
||||||
"src/skeletons",
|
"src/skeletons",
|
||||||
"src/tests"
|
"src/tests",
|
||||||
|
"src/interfaces",
|
||||||
|
"src/utils"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user