Skip to content

Commit

Permalink
add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
cyri113 committed May 19, 2023
1 parent 70c4dd1 commit 0a0e247
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 44 deletions.
24 changes: 11 additions & 13 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": "standard-with-typescript",
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
}
"env": {
"es2021": true,
"node": true
},
"extends": ["standard-with-typescript", "prettier"],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {}
}
2 changes: 1 addition & 1 deletion .github/workflows/start.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ jobs:
ci:
uses: TogetherCrew/operations/.github/workflows/ci.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
coverage
node_modules
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
[![Test Coverage](https://api.codeclimate.com/v1/badges/7f1efd504c8530d6d5b7/test_coverage)](https://codeclimate.com/github/TogetherCrew/typescript-service/test_coverage)

# typescript-service

The starting point template repository for developing typescript microservices. It provides a well-defined structure for building TypeScript-based applications and integrates into the organisations CI/CD workflows.
15 changes: 14 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
"@types/node": "^20.2.1",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^34.0.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"nodemon": "^2.0.22",
"prettier": "^2.8.8",
"prettier": "2.8.8",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
}
Expand Down
12 changes: 6 additions & 6 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import express, { type Express, type Request, type Response } from 'express'
import express, { type Express, type Request, type Response } from "express";

const app: Express = express()
const app: Express = express();

app.get('/', (req: Request, res: Response) => {
res.send('Express + TypeScript Server')
})
app.get("/", (req: Request, res: Response) => {
res.send("Express + TypeScript Server");
});

export default app
export default app;
15 changes: 8 additions & 7 deletions src/config/env.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import Joi from 'joi'
import Joi from "joi";

const schema = Joi
.object()
const schema = Joi.object()
.keys({
PORT: Joi.number().required().default(3000),
})
.unknown()
.unknown();

const { value: env, error } = schema.prefs({ errors: { label: 'key' } }).validate(process.env)
const { value: env, error } = schema
.prefs({ errors: { label: "key" } })
.validate(process.env);

if (error != null) {
throw new Error(`Config validation error: ${error.message}`)
throw new Error(`Config validation error: ${error.message}`);
}

export default env
export default env;
6 changes: 2 additions & 4 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import env from './env'
import env from "./env";

export {
env
}
export { env };
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import app from './app'
import { env } from './config'
import app from "./app";
import { env } from "./config";

app.listen(env.PORT, () => {
console.log(`⚡️[server]: Server is running at http://localhost:${env.PORT}`)
})
console.log(`⚡️[server]: Server is running at http://localhost:${env.PORT}`);
});
14 changes: 7 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand All @@ -25,7 +25,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down Expand Up @@ -55,7 +55,7 @@
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
Expand All @@ -77,12 +77,12 @@
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -104,6 +104,6 @@

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

0 comments on commit 0a0e247

Please sign in to comment.