mirror of
https://github.com/Dkunk7/doto.git
synced 2025-12-10 15:39:34 -06:00
Some basic setup. Server and config files.
This commit is contained in:
commit
35f504dcfc
104
.gitignore
vendored
Normal file
104
.gitignore
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# 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
|
||||||
23
config/connection.js
Normal file
23
config/connection.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const Sequelize = require("sequelize");
|
||||||
|
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
|
// create connection to db
|
||||||
|
let sequelize;
|
||||||
|
|
||||||
|
if (process.env.JAWSDB_URL) {
|
||||||
|
sequelize = new Sequelize(process.env.JAWSDB_URL);
|
||||||
|
} else {
|
||||||
|
sequelize = new Sequelize(
|
||||||
|
process.env.DB_NAME,
|
||||||
|
process.env.DB_USER,
|
||||||
|
process.env.DB_PW,
|
||||||
|
{
|
||||||
|
host: "localhost",
|
||||||
|
dialect: "mysql",
|
||||||
|
port: 3306,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = sequelize;
|
||||||
2
db/db.sql
Normal file
2
db/db.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
DROP DATABASE IF EXISTS doto_db;
|
||||||
|
CREATE DATABASE doto_db;
|
||||||
2947
package-lock.json
generated
Normal file
2947
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
package.json
Normal file
31
package.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"name": "doto",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "\"Professional readme\"",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "node server.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/Dkunk7/doto.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/Dkunk7/doto/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/Dkunk7/doto#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"bcrypt": "^5.1.0",
|
||||||
|
"connect-session-sequelize": "^7.1.5",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"express-handlebars": "^7.0.4",
|
||||||
|
"express-session": "^1.17.3",
|
||||||
|
"mysql2": "^3.2.0",
|
||||||
|
"sequelize": "^6.30.0",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
server.js
Normal file
38
server.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const routes = require("./controllers");
|
||||||
|
const path = require("path");
|
||||||
|
const expbhs = require("express-handlebars");
|
||||||
|
const session = require("express-session");
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const PORT = process.env.PORT || 3001;
|
||||||
|
const hbs = expbhs.create();
|
||||||
|
const SequelizeStore = require("connect-session-sequelize")(session.Store);
|
||||||
|
|
||||||
|
const sess = {
|
||||||
|
secret: process.env.DB_SECRET,
|
||||||
|
cookie: {},
|
||||||
|
resave: false,
|
||||||
|
saveUninitialized: true,
|
||||||
|
store: new SequelizeStore({
|
||||||
|
db: sequelize,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
app.engine("handlebars", hbs.engine);
|
||||||
|
app.set("view engine", "handlebars");
|
||||||
|
|
||||||
|
app.use(express.json());
|
||||||
|
app.use(express.urlencoded({ extended: true }));
|
||||||
|
app.use(express.static(path.join(__dirname, "public")));
|
||||||
|
app.use(session(sess));
|
||||||
|
|
||||||
|
|
||||||
|
// turn on routes
|
||||||
|
app.use(routes);
|
||||||
|
|
||||||
|
// turn on connection to db and server
|
||||||
|
sequelize.sync({ force: false }).then(() => {
|
||||||
|
app.listen(PORT, () => console.log(`Now listening on port ${PORT}`))
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user