-
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.
Merge pull request #1 from TogetherCrew/project-config
Project config
- Loading branch information
Showing
18 changed files
with
7,710 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.github/ | ||
coverage/ | ||
dist/ | ||
node_modules/ | ||
|
||
.env |
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,16 @@ | ||
{ | ||
"env": { | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": ["standard-with-typescript", "prettier"], | ||
"overrides": [], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module", | ||
"project": "./tsconfig.json" | ||
}, | ||
"rules": {}, | ||
"ignorePatterns": ["coverage", "dist"] | ||
} |
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 @@ | ||
name: Staging CI | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
ci: | ||
uses: TogetherCrew/operations/.github/workflows/ci.yml@main | ||
secrets: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} |
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,5 @@ | ||
coverage/ | ||
dist/ | ||
node_modules/ | ||
|
||
.env |
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,3 @@ | ||
dist | ||
coverage | ||
node_modules |
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 @@ | ||
{} |
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,15 @@ | ||
FROM node:18-alpine AS base | ||
WORKDIR /project | ||
COPY . . | ||
RUN npm ci | ||
|
||
FROM base AS test | ||
CMD [ "npx", "jest", "--coverage" ] | ||
|
||
FROM base AS build | ||
RUN npm run build | ||
|
||
FROM build AS prod | ||
RUN npm ci --omit=dev | ||
CMD ["npm", "run", "start"] | ||
EXPOSE 3000 |
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,2 +1,28 @@ | ||
# 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. | ||
|
||
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. | ||
|
||
[![Maintainability](https://api.codeclimate.com/v1/badges/7f1efd504c8530d6d5b7/maintainability)](https://codeclimate.com/github/TogetherCrew/typescript-service/maintainability) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/7f1efd504c8530d6d5b7/test_coverage)](https://codeclimate.com/github/TogetherCrew/typescript-service/test_coverage) | ||
|
||
## Features | ||
|
||
### Linter | ||
|
||
The CI Pipeline uses [super-linter](https://github.com/super-linter/super-linter). You can run it locally with the following command: | ||
|
||
```bash | ||
docker run -e RUN_LOCAL=true -e TYPESCRIPT_DEFAULT_STYLE=prettier -e VALIDATE_DOCKERFILE_HADOLINT=false -v $(pwd):/tmp/lint github/super-linter:slim-latest | ||
``` | ||
|
||
Note: We have disabled HADOLINT for now as we are getting an error: `qemu: uncaught target signal 11 (Segmentation fault) - core dumped`. | ||
|
||
### Tests | ||
|
||
The CI Pipeline uses the `test` target from the Dockerfile to run the tests. You can run it locally with the following command: | ||
|
||
```bash | ||
docker compose -f docker-compose.test.yml up --exit-code-from app | ||
``` | ||
|
||
Note: This will create a /coverage folder where you can review the coverage details. |
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,10 @@ | ||
import request from "supertest"; | ||
import app from "../src/app"; | ||
|
||
describe("GET /", () => { | ||
it("should respond with 'Express + TypeScript Server'", async () => { | ||
const response = await request(app).get("/"); | ||
expect(response.status).toBe(200); | ||
expect(response.text).toBe("Express + TypeScript Server"); | ||
}); | ||
}); |
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,32 @@ | ||
version: "3.9" | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
target: test | ||
dockerfile: Dockerfile | ||
environment: | ||
- PORT=3000 | ||
- MONGODB_HOST=mongo | ||
- MONGODB_PORT=27017 | ||
- MONGODB_USER=root | ||
- MONGODB_PASS=pass | ||
- REDIS_QUEUE_HOST=localhost | ||
- REDIS_QUEUE_PORT=6379 | ||
volumes: | ||
- ./coverage:/project/coverage | ||
depends_on: | ||
- redis | ||
- mongo | ||
redis: | ||
image: "redis:alpine" | ||
ports: | ||
- 6379:6379 | ||
mongo: | ||
image: "mongo" | ||
ports: | ||
- 27017:27017 | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=root | ||
- MONGO_INITDB_ROOT_PASSWORD=pass |
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,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
}; |
Oops, something went wrong.