Skip to content
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

#Ft: Migrate to sendGrid and Add notifications with Socket #40

Open
wants to merge 5 commits into
base: develop
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
212 changes: 212 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"homepage": "https://github.com/denislohan/codehills-be#readme",
"dependencies": {
"@babel/cli": "^7.20.7",
"@sendgrid/mail": "^8.1.1",
"cors": "^2.8.5",
"coveralls": "^3.1.1",
"cron": "^2.3.0",
Expand All @@ -50,6 +51,7 @@
"pg": "^8.9.0",
"pg-hstore": "^2.3.4",
"sequelize": "^6.29.0",
"socket.io": "^4.7.5",
"source-map": "^0.7.4",
"swagger-ui-express": "^4.6.1",
"valibot": "^0.30.0"
Expand Down
11 changes: 10 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-undef */
import express from "express";
import * as http from "http";
import session from "express-session";
import dotenv from "dotenv";
import cors from "cors";
Expand All @@ -8,12 +9,20 @@ import router from "./restful/routes/index";
import fileUploader from "express-fileupload";
import { associate } from "./database/relationships";
import { passport } from "./restful/routes/authRouters";
import {
listenToUserProjectAssigned,
listenToLeadProjectAssigned,
} from "./system/utils/listenToEvent";
import { SocketUtil } from "./system/utils/SocketUtil";
import cronJob from "./system/utils/cronjob";

dotenv.config();

const PORT = process.env.PORT || 4000;

const app = express();
const server = http.createServer(app);
SocketUtil.config(server);
cronJob();
app.use(express.urlencoded({ extended: false }));
app.use(cors());
Expand Down Expand Up @@ -47,7 +56,7 @@ const initializeDatabase = async () => {
const start = () => {
try {
initializeDatabase();
app.listen({ port: PORT }, () =>
server.listen({ port: PORT }, () =>
process.stdout.write(`http://localhost:${PORT} \n`)
);
} catch (error) {
Expand Down
4 changes: 4 additions & 0 deletions src/database/relationships/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export const associate = () => {
DB.FieldReview.belongsTo(DB.RatingField, {
foreignKey: "ratingFieldId",
as: "ratingField",
});
DB.Notification.belongsTo(DB.User, {
foreignKey: "userId",
as: "user",
onDelete: "CASCADE",
});
};
2 changes: 2 additions & 0 deletions src/documentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import search from "./search";
import dashboard from "./auth/dashboard";
import ratingCategories from "./ratingCategory";
import ratingFields from "./ratingField";
import notification from "./notification";

const defaults = swaggerDoc.paths;

Expand All @@ -30,6 +31,7 @@ const paths = {
...search,
...ratingCategories,
...ratingFields,
...notification,
};

const config = {
Expand Down
Loading
Loading