mirror of
https://github.com/filiprojek/nork.git
synced 2024-11-02 10:02:28 +01:00
Remove ignored files
This commit is contained in:
parent
f887fc026a
commit
5eafee03b2
4
.gitignore
vendored
4
.gitignore
vendored
@ -106,4 +106,6 @@ dist
|
|||||||
# package lock file
|
# package lock file
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
|
||||||
_old/
|
_old/
|
||||||
|
undefined.ts
|
||||||
|
undefined.ejs
|
21
_old/LICENSE
21
_old/LICENSE
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2021 Filip Rojek
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@ -1,37 +0,0 @@
|
|||||||
# Nork
|
|
||||||
Simple node.js tool that extends express projects.
|
|
||||||
|
|
||||||
- [About](#about)
|
|
||||||
- [Installation](#installation)
|
|
||||||
- [How to use](#how-to-use)
|
|
||||||
|
|
||||||
## About
|
|
||||||
The point of this tool is to add to express some feeling of php framework Laravel. Primarily get simply express app into MVC architecture.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
```
|
|
||||||
npm install -g nork
|
|
||||||
```
|
|
||||||
This will install nork globally. If you would like to install nork for only one project, you can also install it locally. For local installation:
|
|
||||||
```
|
|
||||||
npm install nork
|
|
||||||
```
|
|
||||||
## How to use
|
|
||||||
```
|
|
||||||
Usage: nork <command> [options]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-v, --version output the version number
|
|
||||||
-h, --help output usage information
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
create [app-name] create a new project
|
|
||||||
create [app-name] -i create a new project in current directory
|
|
||||||
make controller [name] create a new controller
|
|
||||||
make middleware [name] create a new middleware
|
|
||||||
make model [name] create a new model
|
|
||||||
make route [name] create a new route
|
|
||||||
make test [name] create a new test
|
|
||||||
make view [name] create a new view
|
|
||||||
setup set up an existing project for nork
|
|
||||||
```
|
|
@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nork",
|
|
||||||
"version": "1.2.1",
|
|
||||||
"description": "The best node.js 'framework' :)",
|
|
||||||
"main": "src/app.js",
|
|
||||||
"bin": "src/app.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "node src/app.js"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"node",
|
|
||||||
"framework",
|
|
||||||
"express",
|
|
||||||
"mvc"
|
|
||||||
],
|
|
||||||
"author": "Filip Rojek",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"colors": "^1.4.0",
|
|
||||||
"fs-extra": "^10.0.0",
|
|
||||||
"inquirer": "^8.1.2",
|
|
||||||
"pad": "^3.2.0"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/filiprojek/nork.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/filiprojek/nork/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/filiprojek/nork/blob/master/README.md"
|
|
||||||
}
|
|
237
_old/src/app.js
237
_old/src/app.js
@ -1,237 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
const inquirer = require('inquirer')
|
|
||||||
const path = require('path')
|
|
||||||
const fs = require('fs-extra')
|
|
||||||
const colors = require('colors')
|
|
||||||
const pad = require('pad')
|
|
||||||
|
|
||||||
const langToLanguage = lang => {
|
|
||||||
switch (lang) {
|
|
||||||
case 'js':
|
|
||||||
return 'Javascript'
|
|
||||||
case 'ts':
|
|
||||||
return 'Typescript'
|
|
||||||
default:
|
|
||||||
return 'Unknown language'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const logError = errorMsg => {
|
|
||||||
console.log(colors.bgYellow.red(errorMsg))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const logSuccess = (msg = false) => {
|
|
||||||
if (!msg) {
|
|
||||||
msg = 'Success!'
|
|
||||||
}
|
|
||||||
console.log(colors.cyan(msg))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const logHelp = (specific = false, command = false) => {
|
|
||||||
let spc = 27
|
|
||||||
|
|
||||||
if (specific) {
|
|
||||||
// log specific help
|
|
||||||
if (specific == 'make') {
|
|
||||||
console.log(`Usage: ${specific}:[component]`)
|
|
||||||
console.log()
|
|
||||||
console.log(pad(' make controller [name]', spc), 'create a new controller')
|
|
||||||
console.log(pad(' make middleware [name]', spc), 'create a new middleware')
|
|
||||||
console.log(pad(' make model [name]', spc), 'create a new model')
|
|
||||||
console.log(pad(' make route [name]', spc), 'create a new route')
|
|
||||||
console.log(pad(' make test [name]', spc), 'create a new test')
|
|
||||||
console.log(pad(' make view [name]', spc), 'create a new view')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log(`Usage: ${specific} [options]`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Usage: nork <command> [options]')
|
|
||||||
console.log()
|
|
||||||
console.log('Options:')
|
|
||||||
console.log(pad(' -v, --version', spc), 'output the version number')
|
|
||||||
console.log(pad(' -h, --help', spc), 'output usage information')
|
|
||||||
console.log()
|
|
||||||
console.log('Commands:')
|
|
||||||
console.log(pad(' create [app-name]', spc), 'create a new project')
|
|
||||||
console.log(pad(' create [app-name] -i', spc), 'create a new project in current directory')
|
|
||||||
console.log(pad(' make controller [name]', spc), 'create a new controller')
|
|
||||||
console.log(pad(' make interface [name]', spc), 'create a new interface')
|
|
||||||
console.log(pad(' make middleware [name]', spc), 'create a new middleware')
|
|
||||||
console.log(pad(' make model [name]', spc), 'create a new model')
|
|
||||||
console.log(pad(' make route [name]', spc), 'create a new route')
|
|
||||||
console.log(pad(' make service [name]', spc), 'create a new service')
|
|
||||||
console.log(pad(' make test [name]', spc), 'create a new test')
|
|
||||||
console.log(pad(' make view [name]', spc), 'create a new view')
|
|
||||||
console.log(pad(' setup', spc), 'set up an existing project for nork')
|
|
||||||
console.log()
|
|
||||||
console.log(' Run', colors.cyan('nork help <command>'), 'for detailed usage of given command.')
|
|
||||||
|
|
||||||
if (command) {
|
|
||||||
console.log(colors.red('Unknown command'), colors.bold.blue(command))
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
;(async () => {
|
|
||||||
if (process.argv[2] == 'create') {
|
|
||||||
// get info about new project
|
|
||||||
let projectPath
|
|
||||||
const data = {}
|
|
||||||
const questions = [
|
|
||||||
{
|
|
||||||
type: 'input',
|
|
||||||
name: 'project_name',
|
|
||||||
message: 'Enter project name:',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'list',
|
|
||||||
message: "Pick the technology you're using:",
|
|
||||||
name: 'lang',
|
|
||||||
choices: [
|
|
||||||
{ name: 'Typescript', value: 'ts' },
|
|
||||||
{ name: 'Javascript', value: 'js' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'input',
|
|
||||||
name: 'author',
|
|
||||||
message: 'Enter your name:',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
// remove first question if project name is already known
|
|
||||||
if (process.argv[3]) {
|
|
||||||
questions.shift()
|
|
||||||
}
|
|
||||||
|
|
||||||
let answers = await inquirer.prompt(questions)
|
|
||||||
data.project_name = answers.project_name ? answers.project_name : process.argv[3]
|
|
||||||
data.lang = answers.lang
|
|
||||||
data.author = answers.author
|
|
||||||
|
|
||||||
// copy skeleton to new project
|
|
||||||
process.argv.includes('-i') ? (projectPath = process.cwd()) : (projectPath = path.join(process.cwd(), data.project_name))
|
|
||||||
fs.copySync(path.join(__dirname, './skeletons/express-' + data.lang), projectPath)
|
|
||||||
|
|
||||||
// edit package.json file
|
|
||||||
const pkgJson = require(path.join(projectPath, 'package.json'))
|
|
||||||
|
|
||||||
pkgJson.name = data.project_name
|
|
||||||
pkgJson.author = data.author
|
|
||||||
|
|
||||||
fs.writeFile(path.join(projectPath, 'package.json'), JSON.stringify(pkgJson, null, 2), err => {
|
|
||||||
if (err) return logError(err)
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(colors.yellow('Project settings'))
|
|
||||||
console.log(colors.yellow('------------------'))
|
|
||||||
console.log(pad(colors.gray('Project name: '), 30), data.project_name)
|
|
||||||
console.log(pad(colors.gray('Author: '), 30), data.author)
|
|
||||||
console.log(pad(colors.gray('Language: '), 30), langToLanguage(data.lang))
|
|
||||||
|
|
||||||
return logSuccess(`Project ${data.project_name} created successfully!`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv[2] == 'make') {
|
|
||||||
if (!process.argv[3] || !process.argv[4]) return logHelp('make')
|
|
||||||
|
|
||||||
const component = process.argv[3]
|
|
||||||
const norkcfg = require(path.join(process.cwd(), 'norkconfig.json'))
|
|
||||||
|
|
||||||
let tsComponents = ['controller', 'middleware', 'route', 'service']
|
|
||||||
|
|
||||||
if (tsComponents.includes(component)) {
|
|
||||||
let src = path.join(__dirname, './make-files/express-' + norkcfg.lang + '/' + component + '.' + norkcfg.lang)
|
|
||||||
let dest = path.join(process.cwd(), './src/' + component + 's' + '/' + process.argv[4] + '.' + norkcfg.lang)
|
|
||||||
|
|
||||||
try {
|
|
||||||
fs.copySync(src, dest, { overwrite: false, errorOnExist: true })
|
|
||||||
} catch (err) {
|
|
||||||
return logError(err.message)
|
|
||||||
}
|
|
||||||
return logSuccess()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component == 'model') {
|
|
||||||
let src = path.join(__dirname, './make-files/express-' + norkcfg.lang + '/' + component + '.' + norkcfg.lang)
|
|
||||||
let dest = path.join(process.cwd(), './src/' + component + 's' + '/' + process.argv[4] + '.' + norkcfg.lang)
|
|
||||||
|
|
||||||
try {
|
|
||||||
fs.copySync(src, dest, { overwrite: false, errorOnExist: true })
|
|
||||||
} catch (err) {
|
|
||||||
return logError(err.message)
|
|
||||||
}
|
|
||||||
return logSuccess()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component == 'view') {
|
|
||||||
let src = path.join(__dirname, './make-files/express-' + norkcfg.lang + '/' + component + '.ejs')
|
|
||||||
let dest = path.join(process.cwd(), './src/' + component + 's' + '/' + process.argv[4] + '.ejs')
|
|
||||||
|
|
||||||
try {
|
|
||||||
fs.copySync(src, dest, { overwrite: false, errorOnExist: true })
|
|
||||||
} catch (err) {
|
|
||||||
return logError(err.message)
|
|
||||||
}
|
|
||||||
return logSuccess()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component == 'test') {
|
|
||||||
let src = path.join(__dirname, './make-files/express-' + norkcfg.lang + '/' + component + '.js')
|
|
||||||
let dest = path.join(process.cwd(), './src/' + component + 's' + '/' + process.argv[4] + '.test.js')
|
|
||||||
|
|
||||||
try {
|
|
||||||
fs.copySync(src, dest, { overwrite: false, errorOnExist: true })
|
|
||||||
} catch (err) {
|
|
||||||
return logError(err.message)
|
|
||||||
}
|
|
||||||
return logSuccess()
|
|
||||||
}
|
|
||||||
if (component == 'interface') {
|
|
||||||
let src = path.join(__dirname, './make-files/express-' + norkcfg.lang + '/' + component + '.ts')
|
|
||||||
let dest = path.join(process.cwd(), './src/' + component + 's' + '/' + process.argv[4] + '.ts')
|
|
||||||
|
|
||||||
try {
|
|
||||||
fs.copySync(src, dest, { overwrite: false, errorOnExist: true })
|
|
||||||
} catch (err) {
|
|
||||||
return logError(err.message)
|
|
||||||
}
|
|
||||||
return logSuccess()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv[2] == 'setup') {
|
|
||||||
const questions = {
|
|
||||||
type: 'list',
|
|
||||||
message: "Pick the technology you're using:",
|
|
||||||
name: 'lang',
|
|
||||||
choices: [
|
|
||||||
{ name: 'Typescript', value: 'ts' },
|
|
||||||
{ name: 'Javascript', value: 'js' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
let answers = await inquirer.prompt(questions)
|
|
||||||
|
|
||||||
fs.writeJsonSync(path.join(process.cwd(), './norkconfig.json'), answers)
|
|
||||||
return logSuccess()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv[2] == '-v' || process.argv[2] == '--version') {
|
|
||||||
const pkgJson = require(path.join(__dirname, '../package.json'))
|
|
||||||
return console.log('nork', pkgJson.version)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv[2] == 'help' || process.argv[2] == '-h' || process.argv[2] == '--help') {
|
|
||||||
if (process.argv[3]) {
|
|
||||||
return logHelp(process.argv[3])
|
|
||||||
}
|
|
||||||
return logHelp()
|
|
||||||
}
|
|
||||||
|
|
||||||
process.argv.splice(0, 2)
|
|
||||||
logHelp(false, process.argv.join(' '))
|
|
||||||
})()
|
|
@ -1,8 +0,0 @@
|
|||||||
const root_get = (req, res) => {
|
|
||||||
res.render('home')
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
root_get,
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
const { Router } = require('express')
|
|
||||||
|
|
||||||
const router = Router()
|
|
||||||
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
console.log('Hi :)')
|
|
||||||
next()
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = router
|
|
@ -1,17 +0,0 @@
|
|||||||
const mongoose = require('mongoose')
|
|
||||||
const Schema = mongoose.Schema
|
|
||||||
|
|
||||||
const modelSchema = new Schema(
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
timestamps: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
const ModelName = mongoose.model('ModelName', modelSchema)
|
|
||||||
module.exports = ModelName
|
|
@ -1,8 +0,0 @@
|
|||||||
const { Router } = require('express')
|
|
||||||
const rootController = require('../controllers/rootController')
|
|
||||||
|
|
||||||
const router = Router()
|
|
||||||
|
|
||||||
router.get('/', rootController.root_get)
|
|
||||||
|
|
||||||
module.exports = router
|
|
@ -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,15 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>New Project</title>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -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,6 +0,0 @@
|
|||||||
import { Request, Response } from 'express'
|
|
||||||
|
|
||||||
export const root_get = (req: Request, res: Response) => {
|
|
||||||
res.render('home')
|
|
||||||
return true
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@ -1,4 +0,0 @@
|
|||||||
export interface interfaceName {
|
|
||||||
hello: string
|
|
||||||
world: boolean | null | undefined
|
|
||||||
}
|
|
@ -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,8 +0,0 @@
|
|||||||
import { Router, Request, Response, NextFunction } from 'express'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
router.use((req: Request, res: Response, next: NextFunction) => {
|
|
||||||
console.log('Hi :)')
|
|
||||||
next()
|
|
||||||
})
|
|
@ -1,12 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const mongoose_1 = require("mongoose");
|
|
||||||
const modelSchema = new mongoose_1.Schema({
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
timestamps: true,
|
|
||||||
});
|
|
||||||
exports.default = (0, mongoose_1.model)('ModelName', modelSchema);
|
|
@ -1,15 +0,0 @@
|
|||||||
import { Schema, model } from 'mongoose'
|
|
||||||
|
|
||||||
const modelSchema = new Schema<any>(
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
timestamps: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
export default model('ModelName', modelSchema)
|
|
@ -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,6 +0,0 @@
|
|||||||
import { Router } from 'express'
|
|
||||||
import * as rootController from '@/controllers/rootController'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
router.get('/', rootController.root_get)
|
|
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.helloWorld = void 0;
|
|
||||||
function helloWorld() {
|
|
||||||
console.log('hello world');
|
|
||||||
}
|
|
||||||
exports.helloWorld = helloWorld;
|
|
@ -1,3 +0,0 @@
|
|||||||
export function helloWorld() {
|
|
||||||
console.log('hello world')
|
|
||||||
}
|
|
@ -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,15 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>New Project</title>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,2 +0,0 @@
|
|||||||
APP_PORT = 8080
|
|
||||||
DB_URI = 'mongodb://username:password@localhost:27017/database?authSource=admin'
|
|
107
_old/src/skeletons/express-js/.gitignore
vendored
107
_old/src/skeletons/express-js/.gitignore
vendored
@ -1,107 +0,0 @@
|
|||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
|
||||||
typings/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Microbundle cache
|
|
||||||
.rpt2_cache/
|
|
||||||
.rts2_cache_cjs/
|
|
||||||
.rts2_cache_es/
|
|
||||||
.rts2_cache_umd/
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variables file
|
|
||||||
.env
|
|
||||||
.env.test
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# Next.js build output
|
|
||||||
.next
|
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
|
||||||
.nuxt
|
|
||||||
dist
|
|
||||||
|
|
||||||
# Gatsby files
|
|
||||||
.cache/
|
|
||||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
||||||
# public
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# TernJS port file
|
|
||||||
.tern-port
|
|
||||||
|
|
||||||
# package lock file
|
|
||||||
package-lock.json
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"lang": "js"
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "project-name",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "src/app.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "node src/app.js",
|
|
||||||
"dev": "nodemon src/app.js",
|
|
||||||
"test": "jest"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"cors": "^2.8.5",
|
|
||||||
"dotenv": "^8.2.0",
|
|
||||||
"ejs": "^3.1.6",
|
|
||||||
"express": "^4.17.1",
|
|
||||||
"mongoose": "^5.12.3",
|
|
||||||
"morgan": "^1.10.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"jest": "^27.0.6"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
const express = require('express')
|
|
||||||
const morgan = require('morgan')
|
|
||||||
const mongoose = require('mongoose')
|
|
||||||
const dotenv = require('dotenv').config()
|
|
||||||
const cors = require('cors')
|
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
const routes = require('./routes')
|
|
||||||
const middlewares = require('./middlewares')
|
|
||||||
|
|
||||||
const port = process.env.APP_PORT || 8080
|
|
||||||
const app = express()
|
|
||||||
|
|
||||||
// MongoDB
|
|
||||||
const dbURI = process.env.DB_URI
|
|
||||||
mongoose
|
|
||||||
.connect(dbURI, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true })
|
|
||||||
.then(result => {
|
|
||||||
console.log('connected to db')
|
|
||||||
app.listen(port, () => {
|
|
||||||
console.log(`server is running on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
|
|
||||||
// View engine
|
|
||||||
app.set('view engine', 'ejs')
|
|
||||||
|
|
||||||
// Middlewares
|
|
||||||
app.use(middlewares)
|
|
||||||
app.set('views', path.join(__dirname, 'views'))
|
|
||||||
app.use(express.static(path.join(__dirname, 'public')))
|
|
||||||
app.use(cors())
|
|
||||||
app.use(morgan('dev'))
|
|
||||||
app.use(express.urlencoded({ extended: true }))
|
|
||||||
app.use(express.json())
|
|
||||||
|
|
||||||
// Routes
|
|
||||||
app.use(routes)
|
|
@ -1,8 +0,0 @@
|
|||||||
const root_get = (req, res) => {
|
|
||||||
res.render('home')
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
root_get,
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
const { Router } = require('express')
|
|
||||||
const sayHiMiddleware = require('./sayHiMiddleware')
|
|
||||||
|
|
||||||
const router = Router()
|
|
||||||
|
|
||||||
router.use(sayHiMiddleware)
|
|
||||||
|
|
||||||
module.exports = router
|
|
@ -1,10 +0,0 @@
|
|||||||
const { Router } = require('express')
|
|
||||||
|
|
||||||
const router = Router()
|
|
||||||
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
console.log('Hi :)')
|
|
||||||
next()
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = router
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.9 KiB |
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 5.8 KiB |
@ -1,13 +0,0 @@
|
|||||||
const { Router } = require('express')
|
|
||||||
const rootRoutes = require('./rootRoutes')
|
|
||||||
|
|
||||||
const router = Router()
|
|
||||||
|
|
||||||
router.use(rootRoutes)
|
|
||||||
|
|
||||||
// 404
|
|
||||||
router.use((req, res) => {
|
|
||||||
res.status(404).send('E404')
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = router
|
|
@ -1,8 +0,0 @@
|
|||||||
const { Router } = require('express')
|
|
||||||
const rootController = require('../controllers/rootController')
|
|
||||||
|
|
||||||
const router = Router()
|
|
||||||
|
|
||||||
router.get('/', rootController.root_get)
|
|
||||||
|
|
||||||
module.exports = router
|
|
@ -1,9 +0,0 @@
|
|||||||
const { getReq, getRes } = require('./modules/reqRes.module.js')
|
|
||||||
const { root_get } = require('../controllers/rootController.js')
|
|
||||||
|
|
||||||
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 +0,0 @@
|
|||||||
# Folder for utils and other config files
|
|
@ -1,69 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>New Project</title>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
font-family: 'Open Sans', sans-serif;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding-top: 5rem;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
footer, .welcome {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
.welcome {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
width: 200px;
|
|
||||||
padding-top: 2rem;
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
padding-bottom: 2rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.logos {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="content">
|
|
||||||
<div class="welcome">
|
|
||||||
<h1>Let's make something amazing!</h1>
|
|
||||||
<div class="logos">
|
|
||||||
<img src="/nodejs_logo.svg" alt="node.js logo">
|
|
||||||
<img src="/expressjs.png" alt="express.js logo">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer>
|
|
||||||
<div class="author">
|
|
||||||
<p>Made by </p><a href="http://www.filiprojek.cz">filiprojek.cz</a>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
107
_old/src/skeletons/express-ts/.gitignore
vendored
107
_old/src/skeletons/express-ts/.gitignore
vendored
@ -1,107 +0,0 @@
|
|||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
|
||||||
typings/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Microbundle cache
|
|
||||||
.rpt2_cache/
|
|
||||||
.rts2_cache_cjs/
|
|
||||||
.rts2_cache_es/
|
|
||||||
.rts2_cache_umd/
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variables file
|
|
||||||
.env
|
|
||||||
.env.test
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# Next.js build output
|
|
||||||
.next
|
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
|
||||||
.nuxt
|
|
||||||
dist
|
|
||||||
|
|
||||||
# Gatsby files
|
|
||||||
.cache/
|
|
||||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
||||||
# public
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# TernJS port file
|
|
||||||
.tern-port
|
|
||||||
|
|
||||||
# package lock file
|
|
||||||
package-lock.json
|
|
@ -1 +0,0 @@
|
|||||||
# New Project
|
|
@ -1,5 +0,0 @@
|
|||||||
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
|
|
||||||
module.exports = {
|
|
||||||
preset: 'ts-jest',
|
|
||||||
testEnvironment: 'node',
|
|
||||||
};
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"lang": "ts"
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "project-name",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "app.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "node -r tsconfig-paths/register -r ts-node/register dist/server.js",
|
|
||||||
"dev": "nodemon src/server.ts",
|
|
||||||
"test": "jest",
|
|
||||||
"clean": "rimraf dist/*",
|
|
||||||
"copy-assets": "ts-node src/utils/copyAssets",
|
|
||||||
"tsc": "tsc -p .",
|
|
||||||
"build": "npm-run-all clean tsc copy-assets"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"colors": "^1.4.0",
|
|
||||||
"cookie-parser": "^1.4.5",
|
|
||||||
"cors": "^2.8.5",
|
|
||||||
"dotenv": "^8.2.0",
|
|
||||||
"ejs": "^3.1.6",
|
|
||||||
"express": "^4.17.1",
|
|
||||||
"fs-extra": "^10.0.0",
|
|
||||||
"mongoose": "^5.12.3",
|
|
||||||
"morgan": "^1.10.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/cookie-parser": "^1.4.2",
|
|
||||||
"@types/cors": "^2.8.10",
|
|
||||||
"@types/ejs": "^3.0.6",
|
|
||||||
"@types/express": "^4.17.11",
|
|
||||||
"@types/fs-extra": "^9.0.12",
|
|
||||||
"@types/jest": "^27.0.1",
|
|
||||||
"@types/mongoose": "^5.10.5",
|
|
||||||
"@types/morgan": "^1.9.2",
|
|
||||||
"@types/node": "^14.14.41",
|
|
||||||
"@types/shelljs": "^0.8.9",
|
|
||||||
"jest": "^27.0.6",
|
|
||||||
"npm-run-all": "^4.1.5",
|
|
||||||
"rimraf": "^3.0.2",
|
|
||||||
"shelljs": "^0.8.4",
|
|
||||||
"ts-jest": "^27.0.5",
|
|
||||||
"ts-node": "^9.1.1",
|
|
||||||
"tsconfig-paths": "^3.11.0",
|
|
||||||
"typescript": "^4.2.4"
|
|
||||||
},
|
|
||||||
"nodemonConfig": {
|
|
||||||
"ignore": [
|
|
||||||
"**/*.test.ts",
|
|
||||||
"**/*.spec.ts",
|
|
||||||
".git",
|
|
||||||
"node_modules"
|
|
||||||
],
|
|
||||||
"watch": [
|
|
||||||
"src"
|
|
||||||
],
|
|
||||||
"exec": "node -r tsconfig-paths/register -r ts-node/register ./src/server.ts",
|
|
||||||
"ext": "ts, js"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
APP_PORT = 8080
|
|
||||||
DB_URI = 'mongodb://username:password@localhost:27017/database?authSource=admin'
|
|
@ -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,36 +0,0 @@
|
|||||||
import express from 'express'
|
|
||||||
import morgan from 'morgan'
|
|
||||||
import path from 'path'
|
|
||||||
import cors from 'cors'
|
|
||||||
import cookieParser from 'cookie-parser'
|
|
||||||
import { router as routes } from '@/routes'
|
|
||||||
import { router as middlewares } from '@/middlewares'
|
|
||||||
|
|
||||||
const corsWhitelist = ['http://localhost:8080', 'http://localhost:6060']
|
|
||||||
const corsOptions = {
|
|
||||||
origin: function (origin: any, callback: any) {
|
|
||||||
if (!origin || corsWhitelist.indexOf(origin) !== -1) {
|
|
||||||
callback(null, true)
|
|
||||||
} else {
|
|
||||||
callback(new Error('Not allowed by CORS'))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
optionsSuccessStatus: 200,
|
|
||||||
credentials: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
export const app = express()
|
|
||||||
|
|
||||||
// Middlewares
|
|
||||||
app.use(middlewares)
|
|
||||||
app.set('view engine', 'ejs')
|
|
||||||
app.set('views', path.join(__dirname, 'views'))
|
|
||||||
app.use(cors(corsOptions))
|
|
||||||
app.use(morgan('dev'))
|
|
||||||
app.use(express.urlencoded({ extended: true }))
|
|
||||||
app.use(express.json())
|
|
||||||
app.use(express.static(path.join(__dirname, 'public')))
|
|
||||||
app.use(cookieParser())
|
|
||||||
|
|
||||||
// Routes
|
|
||||||
app.use(routes)
|
|
@ -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,6 +0,0 @@
|
|||||||
import { Request, Response } from 'express'
|
|
||||||
|
|
||||||
export const root_get = (req: Request, res: Response) => {
|
|
||||||
res.render('home')
|
|
||||||
return true
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@ -1,4 +0,0 @@
|
|||||||
export interface ErrType {
|
|
||||||
code: number
|
|
||||||
message: string
|
|
||||||
}
|
|
@ -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,6 +0,0 @@
|
|||||||
import { Router } from 'express'
|
|
||||||
import { router as sayHiMiddleware } from '@/middlewares/sayHiMiddleware'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
router.use(sayHiMiddleware)
|
|
@ -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,9 +0,0 @@
|
|||||||
import { Router, Request, Response, NextFunction } from 'express'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
router.use((req: Request, res: Response, next: NextFunction) => {
|
|
||||||
console.log('Hi :)')
|
|
||||||
|
|
||||||
next()
|
|
||||||
})
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.9 KiB |
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 5.8 KiB |
@ -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,11 +0,0 @@
|
|||||||
import { Request, Response, Router } from 'express'
|
|
||||||
import { router as rootRoutes } from './rootRoutes'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
router.use(rootRoutes)
|
|
||||||
|
|
||||||
// 404
|
|
||||||
router.use((req: Request, res: Response) => {
|
|
||||||
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,6 +0,0 @@
|
|||||||
import { Router } from 'express'
|
|
||||||
import * as rootController from '@/controllers/rootController'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
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,24 +0,0 @@
|
|||||||
import mongoose from 'mongoose'
|
|
||||||
import { app } from '@/app'
|
|
||||||
import config from '@/utils/environment'
|
|
||||||
import { Err, Succ } from '@/services/globalService'
|
|
||||||
|
|
||||||
const port: Number = config.APP_PORT || 8080
|
|
||||||
|
|
||||||
// MongoDB
|
|
||||||
const dbURI: string = config.DB_URI
|
|
||||||
mongoose
|
|
||||||
.connect(dbURI, {
|
|
||||||
useNewUrlParser: true,
|
|
||||||
useUnifiedTopology: true,
|
|
||||||
useCreateIndex: true,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
new Succ(200, 'connected to db')
|
|
||||||
app.listen(port, () => {
|
|
||||||
new Succ(200, `Server is listening on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch((err: any) => {
|
|
||||||
new 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,40 +0,0 @@
|
|||||||
import colors from 'colors'
|
|
||||||
import { ErrType } from '@/interfaces/globalInterface'
|
|
||||||
|
|
||||||
export class Err implements ErrType {
|
|
||||||
code: number
|
|
||||||
message: string
|
|
||||||
|
|
||||||
constructor(code: number, message: string) {
|
|
||||||
this.code = code
|
|
||||||
this.message = message
|
|
||||||
this.drop()
|
|
||||||
}
|
|
||||||
|
|
||||||
drop() {
|
|
||||||
console.log(colors.bgRed(`${this.code}`) + colors.bgBlack.red(` ${this.message}`))
|
|
||||||
return {
|
|
||||||
code: this.code,
|
|
||||||
message: this.message,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Succ {
|
|
||||||
code: number
|
|
||||||
message: string
|
|
||||||
|
|
||||||
constructor(code: number, message: string) {
|
|
||||||
this.code = code
|
|
||||||
this.message = message
|
|
||||||
this.drop()
|
|
||||||
}
|
|
||||||
|
|
||||||
drop() {
|
|
||||||
console.log(colors.bgGreen.black(`${this.code}`) + colors.green.bgBlack(` ${this.message}`))
|
|
||||||
return {
|
|
||||||
code: this.code,
|
|
||||||
message: this.message,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,3 +0,0 @@
|
|||||||
export const helloWorld = () => {
|
|
||||||
console.log('hello world')
|
|
||||||
}
|
|
@ -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,7 +0,0 @@
|
|||||||
import * as shell from '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),
|
|
||||||
};
|
|
@ -1,7 +0,0 @@
|
|||||||
import path from 'path'
|
|
||||||
require('dotenv').config({ path: path.join(__dirname, '../.env') })
|
|
||||||
|
|
||||||
export default {
|
|
||||||
APP_PORT: Number(process.env.APP_PORT),
|
|
||||||
DB_URI: String(process.env.DB_URI),
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>New Project</title>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
font-family: 'Open Sans', sans-serif;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding-top: 5rem;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
footer, .welcome {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
.welcome {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
width: 200px;
|
|
||||||
padding-top: 2rem;
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
padding-bottom: 2rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.logos {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="content">
|
|
||||||
<div class="welcome">
|
|
||||||
<h1>Let's make something amazing!</h1>
|
|
||||||
<div class="logos">
|
|
||||||
<img src="/nodejs_logo.svg" alt="node.js logo">
|
|
||||||
<img src="/expressjs.png" alt="express.js logo">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer>
|
|
||||||
<div class="author">
|
|
||||||
<p>Made by </p><a href="http://www.filiprojek.cz">filiprojek.cz</a>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,85 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
||||||
|
|
||||||
/* Basic Options */
|
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
||||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
||||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
||||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
||||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
||||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
||||||
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
||||||
// "composite": true, /* Enable project compilation */
|
|
||||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
||||||
// "removeComments": true, /* Do not emit comments to output. */
|
|
||||||
// "noEmit": true, /* Do not emit outputs. */
|
|
||||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
||||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
||||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
||||||
|
|
||||||
/* Strict Type-Checking Options */
|
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
|
||||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
||||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
||||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
||||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
||||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
||||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
||||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
||||||
|
|
||||||
/* Additional Checks */
|
|
||||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
||||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
||||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
||||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
||||||
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
||||||
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
|
||||||
|
|
||||||
/* Module Resolution Options */
|
|
||||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
||||||
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
||||||
"paths": {
|
|
||||||
"@/*": ["src/","src/*"],
|
|
||||||
"@dist/*": ["dist/*"],
|
|
||||||
"@controllers/*": ["src/controllers/"],
|
|
||||||
"@interfaces/*": ["src/interfaces/*"],
|
|
||||||
"@middlewares/*": ["src/middlewares/*"],
|
|
||||||
"@models/*": ["src/models/*"],
|
|
||||||
"@public/*": ["src/public/*"],
|
|
||||||
"@routes/*": ["src/routes/*"],
|
|
||||||
"@services/*": ["src/services/*"],
|
|
||||||
"@test/*": ["src/test/*"],
|
|
||||||
"@utils/*": ["src/utils/*"],
|
|
||||||
"@validators/*": ["src/validators/*"],
|
|
||||||
"@views/*": ["src/views/*"],
|
|
||||||
},
|
|
||||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
||||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
||||||
// "types": [], /* Type declaration files to be included in compilation. */
|
|
||||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
||||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
||||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
||||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
||||||
|
|
||||||
/* Source Map Options */
|
|
||||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
||||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
||||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
||||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
||||||
|
|
||||||
/* Experimental Options */
|
|
||||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
||||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
||||||
|
|
||||||
/* Advanced Options */
|
|
||||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
||||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
import { Request, Response } from 'express'
|
|
||||||
|
|
||||||
export const root_get = (req: Request, res: Response) => {
|
|
||||||
res.render('home')
|
|
||||||
return true
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
export interface interfaceName {
|
|
||||||
hello: string
|
|
||||||
world: boolean | null | undefined
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
import { Router, Request, Response, NextFunction } from 'express'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
router.use((req: Request, res: Response, next: NextFunction) => {
|
|
||||||
console.log('Hi :)')
|
|
||||||
next()
|
|
||||||
})
|
|
@ -1,15 +0,0 @@
|
|||||||
import { Schema, model } from 'mongoose'
|
|
||||||
|
|
||||||
const modelSchema = new Schema<any>(
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
timestamps: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
export default model('ModelName', modelSchema)
|
|
@ -1,6 +0,0 @@
|
|||||||
import { Router } from 'express'
|
|
||||||
import * as rootController from '@/controllers/rootController'
|
|
||||||
|
|
||||||
export const router = Router()
|
|
||||||
|
|
||||||
router.get('/', rootController.root_get)
|
|
@ -1,3 +0,0 @@
|
|||||||
export function helloWorld() {
|
|
||||||
console.log('hello world')
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>New Project</title>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue
Block a user