-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prettier): Missing Config (#17)
* feat(prettier): Missing Config * style(prettier) * style(prettier)
- Loading branch information
Showing
10 changed files
with
87 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
workflow_dispatch: | ||
|
||
env: | ||
NODE_VERSION: "16.x" | ||
NODE_VERSION: '16.x' | ||
|
||
jobs: | ||
prettier: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
workflow_dispatch: | ||
|
||
env: | ||
NODE_VERSION: "18.x" | ||
NODE_VERSION: '18.x' | ||
|
||
jobs: | ||
prettier: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
workflow_dispatch: | ||
|
||
env: | ||
NODE_VERSION: "20.x" | ||
NODE_VERSION: '20.x' | ||
|
||
jobs: | ||
prettier: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bracketSameLine": true, | ||
"arrowParens": "always", | ||
"trailingComma": "es5", | ||
"bracketSpacing": true, | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
import { Application, Request, Response } from "express"; | ||
import { apiMessage, errorMessage } from "../logger"; | ||
import { existsSync } from "fs"; | ||
import { resolve } from "path"; | ||
import { Application, Request, Response } from 'express'; | ||
import { apiMessage, errorMessage } from '../logger'; | ||
import { existsSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
|
||
export default (app: Application) => { | ||
app.get("/:name", async (req: Request, res: Response) => { | ||
app.get('/:name', async (req: Request, res: Response) => { | ||
try { | ||
const fileName = req.params.name; | ||
apiMessage(req.path, `User is trying to get a file - ${fileName}`); | ||
const fileNamePattern = /^[a-zA-Z0-9_-]+$/; | ||
if (!fileNamePattern.test(fileName)) { | ||
return res.status(400).json({ error: "Invalid file name" }); | ||
return res.status(400).json({ error: 'Invalid file name' }); | ||
} | ||
const filePath = resolve(__dirname, "../", "files", fileName); | ||
const filePath = resolve(__dirname, '../', 'files', fileName); | ||
if (!existsSync(filePath)) { | ||
errorMessage(`File ${fileName} not found`); | ||
return res | ||
.status(404) | ||
.send({ sucsess: false, message: `File ${fileName} not found` }); | ||
return res.status(404).send({ sucsess: false, message: `File ${fileName} not found` }); | ||
} | ||
|
||
apiMessage(req.path, `File ${fileName} found`); | ||
return res.sendFile(filePath); | ||
} catch (err) { | ||
errorMessage(err as string); | ||
return res | ||
.status(500) | ||
.send({ sucsess: false, message: "Internal server error" }); | ||
return res.status(500).send({ sucsess: false, message: 'Internal server error' }); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters