Skip to content

Commit

Permalink
Add Biome tool and CI checks for linting etc. (#3)
Browse files Browse the repository at this point in the history
* add linter

* run lint

* add ci workflow for lint checks etc.

* rename ci job
  • Loading branch information
mickmister authored Jan 17, 2024
1 parent 120e125 commit b42f36d
Show file tree
Hide file tree
Showing 10 changed files with 361 additions and 71 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
ci:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install application dependencies
run: npm ci

- name: Run biome ci process
run: npm run ci
27 changes: 27 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.2/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4
},
"javascript": {
"formatter": {
"enabled": true,
"jsxQuoteStyle": "single",
"semicolons": "always",
"bracketSpacing": false,
"bracketSameLine": false,
"quoteStyle": "single"
}
}
}
228 changes: 228 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"devDependencies": {
"@biomejs/biome": "1.5.2",
"@kitajs/ts-html-plugin": "^1.3.3",
"@types/express": "^4.17.21",
"@types/express-ws": "^3.0.4",
Expand All @@ -24,6 +25,8 @@
"scripts": {
"start": "node dist/server/index.js",
"build": "ts-node esbuild.config.ts",
"lint": "biome lint server",
"ci": "biome ci server",
"start-coverage": "nyc --reporter=lcov --reporter=text ts-node server/src/index.ts",
"dev": "ts-node-dev --respawn --transpile-only server/src/index.ts",
"build-coverage": "COVERAGE=true npm run build",
Expand Down
18 changes: 10 additions & 8 deletions server/src/express_app.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import express, {Router} from 'express';
import expressWs from 'express-ws';

import {initJamRouterWebsocket, jamRouter, renderJamPage} from './modules/jam';
import {loginRouter, renderLoginPage} from './modules/login';
import {AppDependencies} from './types/app_dependencies';
import {renderLayout} from './views/layout';
import {loginRouter, renderLoginPage} from './modules/login';
import {initJamRouterWebsocket, jamRouter, renderJamPage} from './modules/jam';

const handlePage = (renderer: () => string | Promise<string>): express.Handler => async (req, res, next) => {
const page = await Promise.resolve(renderer());
const fullContent = renderLayout(page);
const handlePage =
(renderer: () => string | Promise<string>): express.Handler =>
async (req, res, next) => {
const page = await Promise.resolve(renderer());
const fullContent = renderLayout(page);

res.setHeader('Content-Type', 'text/html');
res.send(fullContent);
};
res.setHeader('Content-Type', 'text/html');
res.send(fullContent);
};

export const initApp = (deps: AppDependencies) => {
const app = expressWs(express()).app;
Expand Down
Loading

0 comments on commit b42f36d

Please sign in to comment.