Skip to content

Commit

Permalink
Merge pull request #135 from bluewave-labs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
uparkalau authored Aug 9, 2024
2 parents db757ce + c9431e1 commit af94990
Show file tree
Hide file tree
Showing 208 changed files with 28,367 additions and 13,629 deletions.
7 changes: 5 additions & 2 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
language: "en-CA"
tone_instructions: "His palms are sweaty, knees weak, arms are heavy There’s vomit on his sweater already, mom’s spaghetti"
early_access: false
reviews:
profile: "assertive"
profile: "chill"
request_changes_workflow: false
high_level_summary: false
poem: false
review_status: true
review_status: false

auto_review:
enabled: true
drafts: false
chat:
auto_reply: false

12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Development Environment Configuration
NODE_ENV=development
PORT=3000
# Database Configuration
DEV_DB_USERNAME=user123
DEV_DB_PASSWORD=password123
DEV_DB_NAME=onboarding_db
DEV_DB_HOST=localhost
DEV_DB_PORT=5432

# JWT Secret Key
JWT_SECRET="NKrbO2lpCsOpVAlqAPsjZ0tZXzIoKru7gAmYZ7XlHn0="
100 changes: 48 additions & 52 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,60 @@ name: Node.js CI

on:
push:
branches:
- "develop"
branches: ["develop", "master"]
pull_request:
branches:
- "develop"
branches: ["develop", "master"]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies for backend
working-directory: ./backend
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Install dependencies for frontend
working-directory: ./frontend
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi

- name: Build backend
working-directory: ./backend
run: npm run build --if-present

- name: Build frontend
working-directory: ./frontend
run: npm run build --if-present

# Uncomment the following lines to run tests
# - name: Run tests for backend
# working-directory: ./backend
# run: npm test

- name: Run tests for frontend
working-directory: ./frontend
run: npm test

- name: Run Docker container
run: docker-compose up --build -d
steps:
- uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies for backend
working-directory: ./backend
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Install dependencies for frontend
working-directory: ./frontend
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Build backend
working-directory: ./backend
run: npm run build --if-present

- name: Build frontend
working-directory: ./frontend
run: npm run build --if-present

# Uncomment the following lines to run tests
# - name: Run tests for backend
# working-directory: ./backend
# run: npm test

- name: Run tests for frontend
working-directory: ./frontend
run: npm test

- name: Run Docker container
run: docker-compose up --build -d
11 changes: 0 additions & 11 deletions backend/.env.development

This file was deleted.

8 changes: 8 additions & 0 deletions backend/.sequelizerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path');

module.exports = {
'config': path.resolve('config', 'config.js'),
'models-path': path.resolve('src', 'models'),
'migrations-path': path.resolve('migrations'),
'seeders-path': path.resolve('seeders')
};
13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:22

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD if [ "$$NODE_ENV" = "production" ] ; then npm run prod ; elif [ "$$NODE_ENV" = "staging" ] ; then npm run staging ; else npm run dev ; fi
27 changes: 10 additions & 17 deletions backend/config/database.js → backend/config/config.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
const { Sequelize } = require('sequelize');
require('dotenv').config(); // Load environment variables from .env file

const databaseConfig = {
require("dotenv").config();
module.exports = {
development: {
username: process.env.DEV_DB_USERNAME,
password: process.env.DEV_DB_PASSWORD,
database: process.env.DEV_DB_NAME,
host: process.env.DEV_DB_HOST,
dialect: 'postgres',
host: 'db',
dialect: "postgres",
port: process.env.DEV_DB_PORT,
logging: false // Disable logging in development mode
logging: false,
},
test: {
username: process.env.TEST_DB_USERNAME,
password: process.env.TEST_DB_PASSWORD,
database: process.env.TEST_DB_NAME,
host: process.env.TEST_DB_HOST,
dialect: 'postgres',
dialect: "postgres",
port: process.env.TEST_DB_PORT,
logging: false // Disable logging in test mode
logging: false,
},
production: {
username: process.env.PROD_DB_USERNAME,
password: process.env.PROD_DB_PASSWORD,
database: process.env.PROD_DB_NAME,
host: process.env.PROD_DB_HOST,
dialect: 'postgres',
dialect: "postgres",
port: process.env.PROD_DB_PORT,
logging: false // Disable logging in production mode
}
logging: false,
},
};

const env = process.env.NODE_ENV || 'development';
const sequelize = new Sequelize(databaseConfig[env]);

module.exports = sequelize;
26 changes: 25 additions & 1 deletion backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,49 @@ const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
const dotenv = require('dotenv');
const bodyParser = require('body-parser');
const jsonErrorMiddleware = require('./src/middleware/jsonErrorMiddleware');

// Load environment variables from .env file
dotenv.config();

const authRoutes = require('./src/routes/auth.routes');
const userRoutes = require('./src/routes/user.routes');
const mocks = require('./src/routes/mocks.routes');
const popup = require('./src/routes/popup.routes');
const popup_log = require('./src/routes/popup_log.routes');
// const tourRoutes = require('./src/routes/tour.routes');

const app = express();

app.use(cors());
app.use(helmet());
app.use(express.json());
app.use(bodyParser.json());
app.use(jsonErrorMiddleware);

const { sequelize } = require("./src/models");

sequelize
.authenticate()
.then(() => console.log("Database connected..."))
.catch((err) => console.log("Error: " + err));

sequelize
.sync({force:true})
.then(() => console.log("Models synced with the database..."))
.catch((err) => console.log("Error syncing models: " + err));

app.use('/auth', authRoutes);
app.use('/users', userRoutes);
app.use('/mock/', mocks);
app.use('/popup', popup);
app.use('/popup_log', popup_log);
// app.use('/tours', tourRoutes);

app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).json({ message: 'Internal Server Error' });
res.status(500).json({ message: "Internal Server Error" });
});

const PORT = process.env.PORT || 3000;
Expand Down
25 changes: 12 additions & 13 deletions backend/migrations/20240422214219-create_users_table.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
'use strict';
"use strict";

/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('users', {
await queryInterface.createTable("users", {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
autoIncrement: true,
},
username: {
type: Sequelize.STRING(50),
allowNull: false,
unique: true
unique: true,
},
email: {
type: Sequelize.STRING(100),
allowNull: false,
unique: true
unique: true,
},
password: {
type: Sequelize.STRING(100),
allowNull: false
allowNull: false,
},
role: {
type: Sequelize.STRING(20),
allowNull: false,
defaultValue: 'user'
defaultValue: "user",
},
created_at: {
createdAt: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
},
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('users');
}
await queryInterface.dropTable("users");
},
};

64 changes: 64 additions & 0 deletions backend/migrations/20240601230258-create-popup-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"use strict";

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("popup", {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
closeButtonAction: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isIn: [["no-action", "open-url", "close-popup", "open-url-new-tab"]],
},
},
popupSize: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isIn: [["small", "medium", "large"]],
},
},
url: {
type: Sequelize.STRING,
allowNull: true,
},
actionButtonText: {
type: Sequelize.STRING,
allowNull: true,
},
headerBackgroundColor: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: "#FFFFFF",
},
headerColor: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: "#FFFFFF",
},
textColor: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: "#FFFFFF",
},
buttonBackgroundColor: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: "#FFFFFF",
},
buttonTextColor: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: "#FFFFFF",
},
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("popup");
},
};
Loading

0 comments on commit af94990

Please sign in to comment.