Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.
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
33 changes: 29 additions & 4 deletions .github/workflows/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:

- name: Install dependencies
working-directory: ./api
run: npm install
run: yarn install

- name: Check formatting
working-directory: ./api
run: npm run format:check
run: yarn format:check

lint:
runs-on: ubuntu-latest
Expand All @@ -47,8 +47,33 @@ jobs:

- name: Install dependencies
working-directory: ./api
run: npm install
run: yarn install

- name: Run linter
working-directory: ./api
run: npm run lint
run: yarn lint

test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 12

- name: Cache dependencies
uses: actions/cache@v2
with:
path: api/node_modules
key: ${{ runner.os }}-cache

- name: Install dependencies
working-directory: ./api
run: yarn install

- name: Run tests
working-directory: ./api
run: yarn test
12 changes: 6 additions & 6 deletions .github/workflows/client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:

- name: Install dependencies
working-directory: ./client
run: npm install
run: yarn install

- name: Check formatting
working-directory: ./client
run: npm run format:check
run: yarn format:check

lint:
runs-on: ubuntu-latest
Expand All @@ -47,11 +47,11 @@ jobs:

- name: Install dependencies
working-directory: ./client
run: npm install
run: yarn install

- name: Run linter
working-directory: ./client
run: npm run lint
run: yarn lint

build:
runs-on: ubuntu-latest
Expand All @@ -72,8 +72,8 @@ jobs:

- name: Install dependencies
working-directory: ./client
run: npm install
run: yarn install

- name: Build application
working-directory: ./client
run: npm run build
run: yarn build
5 changes: 4 additions & 1 deletion api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"plugins": ["@h4iuiuc"],
"extends": ["plugin:@h4iuiuc/recommended"]
"extends": ["plugin:@h4iuiuc/recommended"],
"env": {
"jest": true
}
}
13 changes: 12 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"format:check": "prettier --check \"./**/*.{js,jsx,json,md}\"",
"lint": "eslint \"./**/*.js\"",
"lint:fix": "eslint --fix \"./**/*.js\"",
"test": "cross-env NODE_ENV=test jest --testTimeout=10000",
"start": "nodemon ./src/bin/www"
},
"dependencies": {
Expand All @@ -15,12 +16,22 @@
"debug": "~2.6.9",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"http-status-codes": "^2.1.4",
"morgan": "~1.9.1",
"nodemon": "^2.0.4"
},
"devDependencies": {
"@h4iuiuc/eslint-plugin": "^1.0.12",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"prettier": "^2.0.5"
"jest": "^26.4.2",
"prettier": "^2.0.5",
"supertest": "^5.0.0"
},
"jest": {
"testEnvironment": "node",
"coveragePathIgnorePatterns": [
"/node_modules/"
]
}
}
2 changes: 1 addition & 1 deletion api/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));

app.use("/", indexRouter);
app.use("/api", indexRouter);

// catch 404 and forward to error handler
app.use(function (req, res, next) {
Expand Down
7 changes: 4 additions & 3 deletions api/src/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var express = require("express");
var router = express.Router();
const express = require("express");
const router = express.Router();
const statusCodes = require("http-status-codes");

/* GET home page. */
router.get("/", function (req, res) {
res.send("Closegap!");
res.status(statusCodes.OK).send("Closegap!");
});

module.exports = router;
11 changes: 11 additions & 0 deletions api/tests/routes.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const request = require("supertest");
const app = require("../src/app");
const statusCodes = require("http-status-codes");

describe("Get Endpoints", () => {
it("should get our project name", async () => {
const res = await request(app).get("/api");
expect(res.statusCode).toEqual(statusCodes.OK);
expect(res.text).toEqual("Closegap!");
});
});