Skip to content

Commit

Permalink
Merge pull request #37 from ASparton/feat/setup-back-end-linter-and-f…
Browse files Browse the repository at this point in the history
…ormatter

Feat/setup back end linter and formatter
  • Loading branch information
ASparton authored Nov 20, 2023
2 parents 8ac710a + b5d1b12 commit 05f4e63
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run format && npm run lint && git add .
16 changes: 16 additions & 0 deletions back/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://biomejs.dev/schemas/1.3.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"indentStyle": "tab",
"indentWidth": 2
}
}
4 changes: 2 additions & 2 deletions back/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"preset": "ts-jest",
"testEnvironment": "node"
"preset": "ts-jest",
"testEnvironment": "node"
}
122 changes: 122 additions & 0 deletions back/package-lock.json

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

5 changes: 4 additions & 1 deletion back/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"license": "MIT",
"scripts": {
"dev": "tsx watch src/index.ts",
"test": "jest"
"test": "jest",
"lint": "biome lint src/",
"format": "biome format --write src/"
},
"dependencies": {
"@lucia-auth/adapter-prisma": "^3.0.2",
Expand All @@ -13,6 +15,7 @@
"lucia": "^2.7.4"
},
"devDependencies": {
"@biomejs/biome": "1.3.3",
"@types/express": "4.17.21",
"@types/jest": "^29.5.8",
"@types/node": "20.9.0",
Expand Down
4 changes: 2 additions & 2 deletions back/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PrismaClient, Prisma } from '@prisma/client'
import { PrismaClient, Prisma } from "@prisma/client";

const prisma = new PrismaClient()
const prisma = new PrismaClient();

// async function main() {
// console.log(`Start seeding ...`)
Expand Down
12 changes: 6 additions & 6 deletions back/src/apiErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import APIError from "./types/APIError";
import HttpStatusCode from "./types/HttpStatusCode";

export const ResourceNotFound: APIError = {
id: "RESOURCE_NOT_FOUND",
code: HttpStatusCode.NOT_FOUND_404,
}
id: "RESOURCE_NOT_FOUND",
code: HttpStatusCode.NOT_FOUND_404,
};

export const InvalidCredentials: APIError = {
id: "INVALID_CREDENTIALS",
code: HttpStatusCode.BAD_REQUEST_400
}
id: "INVALID_CREDENTIALS",
code: HttpStatusCode.BAD_REQUEST_400,
};
20 changes: 10 additions & 10 deletions back/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import express from 'express'
import express from "express";

const app = express()
const app = express();

app.use(express.json())
app.use(express.json());

app.get('/status', (req, res) => {
res.send({ healthy: true })
})
app.get("/status", (req, res) => {
res.send({ healthy: true });
});

const PORT = 3000
const PORT = 3000;

const server = app.listen(PORT, () => console.log(
`🚀 Server ready at: http://localhost:${PORT}`
))
const server = app.listen(PORT, () =>
console.log(`🚀 Server ready at: http://localhost:${PORT}`),
);
4 changes: 2 additions & 2 deletions back/src/types/APIError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import APIErrorId from './APIErrorId';
import HttpStatusCode from './HttpStatusCode';
import APIErrorId from "./APIErrorId";
import HttpStatusCode from "./HttpStatusCode";

type APIError = {
id: APIErrorId;
Expand Down
6 changes: 1 addition & 5 deletions back/src/types/APIErrorId.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
type APIErrorId =
'INVALID_CREDENTIALS' |
'RESOURCE_NOT_FOUND' |
'UNAUTHORIZED'
;
type APIErrorId = "INVALID_CREDENTIALS" | "RESOURCE_NOT_FOUND" | "UNAUTHORIZED";

export default APIErrorId;
4 changes: 2 additions & 2 deletions back/src/types/HttpStatusCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ enum HttpStatusCode {
* Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
* to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
*/
NETWORK_AUTHENTICATION_REQUIRED_511 = 511
NETWORK_AUTHENTICATION_REQUIRED_511 = 511,
}

export default HttpStatusCode;
export default HttpStatusCode;
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
"semantic-release": "^22.0.7"
},
"scripts": {
"setup": "npm i && npx husky install && chmod u+x .husky/commit-msg"
"setup": "npm i && npx husky install && chmod u+x .husky/commit-msg && chmod u+x .husky/pre-commit",
"lint": "npm run lint-back",
"format": "npm run format-back",
"lint-back": "cd back && npm run lint",
"format-back": "cd back && npm run format"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 05f4e63

Please sign in to comment.