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

Create monorepo for the frontend and backend #2

Merged
merged 4 commits into from Mar 22, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Initial backend commit

Set up the backend project with eslint configs, the tsconfig, initial
prototypes for the Mongo model and schema, express routing
  • Loading branch information
afnanenayet committed Mar 22, 2020
commit 3cd56fd12935034a560cc7cc70f3dedc08e295a8
@@ -0,0 +1,6 @@
dist/*
coverage/*
# data definition files
**/*.d.ts
# 3rd party libs
/src/public/
@@ -0,0 +1,48 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"semi": [
"error",
"always"
],
"indent": [
"error",
4
],
"quotes": [
"error",
"double"
],
"array-bracket-spacing": [
"error",
"never"
],
"explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": 1,
"@typescript-eslint/no-inferrable-types": [
"warn",
{
"ignoreParameters": true
}
],
"no-unused-vars": "warn"
}
}

Large diffs are not rendered by default.

@@ -0,0 +1,100 @@
{
"name": "coronajobs-backend",
"version": "0.1.0",
"description": "The backend server for coronajobs.info",
"repository": {
"type": "git",
"url": ""
},
"author": "Afnan Enayet, Akashdeep Deb",
"license": "MIT",
"scripts": {
"start": "npm run serve",
"build": "npm run build-ts && npm run lint",
"serve": "node dist/server.js",
"watch-node": "nodemon dist/server.js",
"watch": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run watch-node\"",
"test": "jest --forceExit --coverage --verbose",
"watch-test": "npm run test -- --watchAll",
"build-ts": "tsc",
"watch-ts": "tsc -w",
"lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix",
"debug": "npm run build && npm run watch-debug",
"serve-debug": "nodemon --inspect dist/server.js",
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run serve-debug\""
},
"dependencies": {
"async": "^3.1.0",
"bcrypt-nodejs": "^0.0.3",
"bluebird": "^3.5.5",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"connect-mongo": "^3.0.0",
"dotenv": "^8.2.0",
"errorhandler": "^1.5.1",
"express": "^4.17.1",
"express-flash": "0.0.2",
"express-session": "^1.16.2",
"express-validator": "^6.2.0",
"fbgraph": "^1.4.4",
"lodash": "^4.17.15",
"lusca": "^1.6.1",
"mongoose": "^5.7.5",
"nodemailer": "^6.3.0",
"passport": "^0.4.0",
"passport-facebook": "^3.0.0",
"passport-local": "^1.0.0",
"pug": "^2.0.4",
"winston": "^3.2.1"
},
"devDependencies": {
"@types/async": "^3.0.2",
"@types/bcrypt-nodejs": "^0.0.30",
"@types/bluebird": "^3.5.27",
"@types/body-parser": "^1.17.1",
"@types/chai": "^4.2.3",
"@types/compression": "^1.0.1",
"@types/concurrently": "^4.1.0",
"@types/connect-mongo": "^3.0.0",
"@types/errorhandler": "^0.0.32",
"@types/eslint": "^6.1.1",
"@types/express": "^4.17.1",
"@types/express-flash": "0.0.1",
"@types/express-session": "^1.15.14",
"@types/jest": "^24.0.23",
"@types/jquery": "^3.3.31",
"@types/lodash": "^4.14.141",
"@types/lusca": "^1.6.1",
"@types/mongoose": "^5.5.18",
"@types/node": "^12.7.8",
"@types/node-sass": "^4.11.0",
"@types/nodemailer": "^6.2.1",
"@types/passport": "^1.0.1",
"@types/passport-facebook": "^2.1.9",
"@types/passport-local": "^1.0.33",
"@types/pug": "^2.0.4",
"@types/request": "^2.48.3",
"@types/request-promise": "^4.1.44",
"@types/shelljs": "^0.8.5",
"@types/supertest": "^2.0.8",
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"chai": "^4.2.0",
"concurrently": "^5.0.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"jest": "^24.9.0",
"node-sass": "^4.13.0",
"nodemon": "^1.19.2",
"shelljs": "^0.8.3",
"supertest": "^4.0.2",
"ts-jest": "^24.1.0",
"ts-node": "^8.4.1",
"typescript": "^3.6.3"
}
}
@@ -0,0 +1,19 @@
import express from "express";
import compression from "compression";
import bodyParser from "body-parser";

import * as apiController from "./controllers/api";

// Create Express server
const app = express();

// Express configuration
app.set("port", process.env.PORT || 3000);
app.use(compression());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

// API routes
app.get("/api", apiController.getApi);

export default app;
@@ -0,0 +1,13 @@
"use strict;";

import { Response, Request } from "express";

/**
* GET /api
* List of API examples.
*/
export const getApi = (_req: Request, res: Response) => {
res.render("api/index", {
title: "Welcome to my API"
});
};
@@ -0,0 +1,50 @@
import mongoose from "mongoose";

/**
* The information related to a job posting
*/
export type JobPost = mongoose.Document & {
/**
* The title of the job post
*/
title: String,

/**
* A brief description of the job posting. This should not be the full job
* description.
*/
shortDescription: String,

/**
* The tags for a job description should be concise. There shouldn't be too
* many, just enough to get an idea of what kind of job this is. The list
* of tags must be unique.
*/
tags: String[],

/**
* A URL to the actual job post
*/
url: String,

/**
* An optional location for the job
*/
location: String,

/**
* Whether the job allows for remote work
*/
isRemote: Boolean,
};

// We include timestamps because then Mongo can automatically track when posts
// were created/last updated
const jobSchema: mongoose.Schema<JobPost> = new mongoose.Schema({
title: String,
shortDescription: String,
tags: Array,
url: String,
location: String,
isRemote: Boolean
}, { timestamps: true });
@@ -0,0 +1,15 @@
import app from "./app";

/**
* Start Express server.
*/
const server = app.listen(app.get("port"), () => {
console.log(
" App is running at http://localhost:%d in %s mode",
app.get("port"),
app.get("env")
);
console.log(" Press CTRL-C to stop\n");
});

export default server;
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
}
},
"include": [
"src/**/*"
]
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.