Skip to content

Commit

Permalink
update image, users, card, card group module
Browse files Browse the repository at this point in the history
  • Loading branch information
longpddev committed Sep 4, 2022
1 parent bbc619e commit 674eb33
Show file tree
Hide file tree
Showing 38 changed files with 999 additions and 71 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
DB_USER=root
DB_PASS=123456
DB_NAME_DEVELOPMENT=project
DB_NAME_DEVELOPMENT=project4
DB_HOST=localhost
DB_PORT=3306
DB_DIALECT=mariadb
DB_NAME_TEST=project
DB_NAME_DEVELOPMENT=project
DB_NAME_PRODUCTION=project
DB_NAME_TEST=project4
DB_NAME_DEVELOPMENT=project4
DB_NAME_PRODUCTION=project4
JWTKEY=wfx1OcqE8uTPAWRW5eCqUdKRw8hDRnQp
TOKEN_EXPIRATION=72h
BEARER=Bearer
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Nest Framework",
"args": [
"${workspaceFolder}/src/main.ts"
],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register",
"-r",
"tsconfig-paths/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}",
"protocol": "inspector"
}
]
}
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"editor.formatOnSave": true,
"compile-hero.disable-compile-files-on-did-save-code": true
"compile-hero.disable-compile-files-on-did-save-code": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"node_modules": true
}
}
23 changes: 23 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"development": {
"username": "root",
"password": 123456,
"database": "project2",
"host": "localhost",
"dialect": "mariadb"
},
"test": {
"username": "root",
"password": 123456,
"database": "project2",
"host": "localhost",
"dialect": "mariadb"
},
"production": {
"username": "root",
"password": 123456,
"database": "project2",
"host": "localhost",
"dialect": "mariadb"
}
}
37 changes: 37 additions & 0 deletions models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};

let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}

fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(file => {
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
db[model.name] = model;
});

Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
Loading

0 comments on commit 674eb33

Please sign in to comment.