Skip to content

Feature/adc 493 almost backend completed and frontend setup #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PORT=5000
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=road_infra_dashboard
DB_PORT=5432
DB_DIALECT=postgres
JWT_SECRET="your-secret-key-change-in-production"
NODE_ENV="development"
139 changes: 139 additions & 0 deletions municipal-road-taxonomy-and-infra-tracker/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-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/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# 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 variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# 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

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.vscode
/node_modules
./dist


*.env
.env
.env.*
10 changes: 10 additions & 0 deletions municipal-road-taxonomy-and-infra-tracker/backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"arrowParens": "always"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// .sequelizerc
const path = require('path');

module.exports = {
'config': path.resolve('src', 'database', 'db.config.cjs'),
'migrations-path': path.resolve('src', 'database', 'migrations'),
'seeders-path': path.resolve('src', 'database', 'seeders'),
'models-path': path.resolve('src', 'models'),
};
38 changes: 38 additions & 0 deletions municipal-road-taxonomy-and-infra-tracker/backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "road-infra-dashboard-backend",
"version": "1.0.0",
"description": "Backend for Road Nomenclature & Infra Monitoring Dashboard",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js",
"dev": "nodemon src/index.js",
"db:seed": "node src/seeders/index.js",
"db:migrate": "sequelize-cli db:migrate",
"db:migrate:undo": "sequelize-cli db:migrate:undo",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"express",
"sequelize",
"postgresql"
],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.1",
"express": "^4.18.2",
"express-validator": "^7.0.1",
"jsonwebtoken": "^9.0.2",
"morgan": "^1.10.0",
"pg": "^8.11.3",
"pg-hstore": "^2.3.4",
"sequelize": "^6.35.2",
"csv-writer": "^1.6.0"
},
"devDependencies": {
"nodemon": "^3.0.3",
"sequelize-cli": "^6.6.2"
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require('dotenv').config();

module.exports = {
development: {
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: process.env.DB_DIALECT,
logging: false,
},
test: {
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME + '_test',
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: process.env.DB_DIALECT,
logging: false,
},
production: {
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: process.env.DB_DIALECT,
logging: false,
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false,
},
},
},
};
34 changes: 34 additions & 0 deletions municipal-road-taxonomy-and-infra-tracker/backend/src/config/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Sequelize } = require('sequelize');
require('dotenv').config();

const sequelize = new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASSWORD,
{
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: process.env.DB_DIALECT,
logging: process.env.NODE_ENV === 'development' ? console.log : false,
dialectOptions:
process.env.NODE_ENV === 'production'
? {
ssl: {
require: true,
rejectUnauthorized: false,
},
}
: {},
}
);

const testConnection = async () => {
try {
await sequelize.authenticate();
console.log('Database connection has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error);
}
};

module.exports = { sequelize, testConnection };
Loading