mirror of
https://github.com/filiprojek/nork.git
synced 2025-02-20 01:22:58 +01:00
code formatted
This commit is contained in:
@ -14,7 +14,7 @@ export default class Create {
|
||||
{
|
||||
type: 'input',
|
||||
name: 'project_name',
|
||||
message: 'Enter project name:',
|
||||
message: 'Enter project name:'
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
@ -22,8 +22,8 @@ export default class Create {
|
||||
name: 'lang',
|
||||
choices: [
|
||||
{ name: 'Typescript', value: 'ts' },
|
||||
{ name: 'Javascript - DEPRECATED', value: 'js' },
|
||||
],
|
||||
{ name: 'Javascript - DEPRECATED', value: 'js' }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
@ -32,24 +32,24 @@ export default class Create {
|
||||
choices: [
|
||||
{ name: 'MongoDB - Mongoose', value: { db: 'mongodb', orm: 'mongoose' } },
|
||||
{ name: 'MySQL - Sequelize', value: { db: 'mysql', orm: 'sequelize' } },
|
||||
{ name: 'PostgreSQL - Sequelize', value: { db: 'postgresql', orm: 'sequelize' } },
|
||||
],
|
||||
{ name: 'PostgreSQL - Sequelize', value: { db: 'postgresql', orm: 'sequelize' } }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'author',
|
||||
message: 'Enter your name:',
|
||||
message: 'Enter your name:'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'email',
|
||||
message: 'Enter your email:',
|
||||
message: 'Enter your email:'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'website',
|
||||
message: 'Enter your website:',
|
||||
},
|
||||
message: 'Enter your website:'
|
||||
}
|
||||
]
|
||||
// remove first question if project name is already known
|
||||
if (projectName) questions.shift()
|
||||
@ -61,7 +61,7 @@ export default class Create {
|
||||
author: answers.author,
|
||||
database: answers.db,
|
||||
website: answers.website,
|
||||
email: answers.email,
|
||||
email: answers.email
|
||||
}
|
||||
|
||||
// copy skeleton to new project
|
||||
@ -76,7 +76,7 @@ export default class Create {
|
||||
const pkgJson = fs.readJsonSync(path.join(projectPath, 'package.json'))
|
||||
pkgJson.name = data.project_name
|
||||
pkgJson.author = `${data.author} <${data.email}> (${data.website})`
|
||||
fs.writeFile(path.join(projectPath, 'package.json'), JSON.stringify(pkgJson, null, 2), err => {
|
||||
fs.writeFile(path.join(projectPath, 'package.json'), JSON.stringify(pkgJson, null, 2), (err) => {
|
||||
if (err) return global.logError(err.message)
|
||||
})
|
||||
|
||||
|
@ -10,6 +10,6 @@ export interface Questions {
|
||||
{
|
||||
name: string
|
||||
value: string
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ const root_get = (req, res) => {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
root_get,
|
||||
root_get
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ const modelSchema = new Schema(
|
||||
{
|
||||
title: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
required: true
|
||||
}
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
},
|
||||
timestamps: true
|
||||
}
|
||||
)
|
||||
|
||||
const ModelName = mongoose.model('ModelName', modelSchema)
|
||||
|
@ -4,12 +4,12 @@ const modelSchema = new Schema<any>(
|
||||
{
|
||||
title: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
required: true
|
||||
}
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
},
|
||||
timestamps: true
|
||||
}
|
||||
)
|
||||
|
||||
export default model('ModelName', modelSchema)
|
||||
|
@ -13,8 +13,8 @@ export default class Setup {
|
||||
name: 'lang',
|
||||
choices: [
|
||||
{ name: 'Typescript', value: 'ts' },
|
||||
{ name: 'Javascript', value: 'js' },
|
||||
],
|
||||
{ name: 'Javascript', value: 'js' }
|
||||
]
|
||||
}
|
||||
const answers = await inquirer.prompt(Object(questions))
|
||||
fs.writeJsonSync(path.join(process.cwd(), './norkconfig.json'), answers)
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"lang": "js"
|
||||
}
|
||||
"lang": "js"
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ const app = express()
|
||||
const dbURI = process.env.DB_URI
|
||||
mongoose
|
||||
.connect(dbURI, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true })
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
console.log('connected to db')
|
||||
app.listen(port, () => {
|
||||
console.log(`server is running on http://localhost:${port}`)
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
|
@ -4,5 +4,5 @@ const root_get = (req, res) => {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
root_get,
|
||||
root_get
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
# Folder for utils and other config files
|
||||
# Folder for utils and other config files
|
||||
|
@ -11,5 +11,5 @@
|
||||
"vueIndentScriptAndStyle": true,
|
||||
"arrowParens": "always",
|
||||
"bracketSameLine": false,
|
||||
"endOfLine": "lf"
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"lang": "ts",
|
||||
"db": "",
|
||||
"orm": ""
|
||||
}
|
||||
"lang": "ts",
|
||||
"db": "",
|
||||
"orm": ""
|
||||
}
|
||||
|
@ -1,73 +1,73 @@
|
||||
{
|
||||
"name": "project-name",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "dist/server.js",
|
||||
"private": "true",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"repository": "github:username/repo",
|
||||
"license": "ISC",
|
||||
"scripts": {
|
||||
"start": "node dist/server.js",
|
||||
"start:dev": "nodemon src/server.ts",
|
||||
"test": "jest",
|
||||
"clean": "rimraf dist/*",
|
||||
"copy-assets": "npx ts-node src/utils/copyAssets",
|
||||
"tsc": "tsc -p .",
|
||||
"build": "npm-run-all clean tsc copy-assets",
|
||||
"name": "project-name",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "dist/server.js",
|
||||
"private": "true",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"repository": "github:username/repo",
|
||||
"license": "ISC",
|
||||
"scripts": {
|
||||
"start": "node dist/server.js",
|
||||
"start:dev": "nodemon src/server.ts",
|
||||
"test": "jest",
|
||||
"clean": "rimraf dist/*",
|
||||
"copy-assets": "npx ts-node src/utils/copyAssets",
|
||||
"tsc": "tsc -p .",
|
||||
"build": "npm-run-all clean tsc copy-assets",
|
||||
"format": "npx prettier --write ."
|
||||
},
|
||||
"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",
|
||||
"express-validator": "^6.14.2",
|
||||
"fs-extra": "^10.0.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"mongoose": "^5.12.3",
|
||||
"pg": "^8.7.1",
|
||||
"pg-hstore": "^2.3.4",
|
||||
"sequelize": "^6.15.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.5.2",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"@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.1.5",
|
||||
"ts-node": "^10.8.1",
|
||||
"typescript": "^4.2.4",
|
||||
"morgan": "^1.10.0"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"ignore": [
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts",
|
||||
".git",
|
||||
"node_modules"
|
||||
],
|
||||
"watch": [
|
||||
"src"
|
||||
],
|
||||
"ext": "ts, js"
|
||||
}
|
||||
},
|
||||
"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",
|
||||
"express-validator": "^6.14.2",
|
||||
"fs-extra": "^10.0.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"mongoose": "^5.12.3",
|
||||
"pg": "^8.7.1",
|
||||
"pg-hstore": "^2.3.4",
|
||||
"sequelize": "^6.15.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.5.2",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"@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.1.5",
|
||||
"ts-node": "^10.8.1",
|
||||
"typescript": "^4.2.4",
|
||||
"morgan": "^1.10.0"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"ignore": [
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts",
|
||||
".git",
|
||||
"node_modules"
|
||||
],
|
||||
"watch": [
|
||||
"src"
|
||||
],
|
||||
"ext": "ts, js"
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
/* 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",
|
||||
|
||||
|
@ -10,26 +10,26 @@ Instance.init(
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
unique: true
|
||||
},
|
||||
username: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
allowNull: false
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
allowNull: false
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
unique: true
|
||||
}
|
||||
},
|
||||
{
|
||||
sequelize: db,
|
||||
tableName: path.basename(__filename).split('.')[0].toLowerCase(),
|
||||
},
|
||||
tableName: path.basename(__filename).split('.')[0].toLowerCase()
|
||||
}
|
||||
)
|
||||
|
||||
export default Instance
|
||||
|
Reference in New Issue
Block a user