Feature: Initial skeleton for the app (#1)

This commit is contained in:
Timothee Guerin 2019-05-15 13:20:50 -07:00 коммит произвёл GitHub
Родитель f82333d1cc
Коммит 483c6c2437
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
23 изменённых файлов: 11387 добавлений и 3 удалений

32
.ci/ci.yml Normal file
Просмотреть файл

@ -0,0 +1,32 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
pool:
vmImage: 'Ubuntu 16.04'
trigger:
- master
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
- script: npm ci
displayName: 'Install dependencies'
- script: npm run test
displayName: 'Test'
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: ./test-results.xml
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage'
- script: npm run lint
displayName: 'Lint'

6
.gitignore поставляемый
Просмотреть файл

@ -36,9 +36,6 @@ build/Release
node_modules/ node_modules/
jspm_packages/ jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory # Optional npm cache directory
.npm .npm
@ -59,3 +56,6 @@ typings/
# next.js build output # next.js build output
.next .next
bin/
buildcache/

2
.prettierrc.yml Normal file
Просмотреть файл

@ -0,0 +1,2 @@
trailingComma: "all"
printWidth: 120

14
.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run server",
"program": "${workspaceFolder}/src/main.ts",
"outFiles": ["${workspaceFolder}/bin/main.js"],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}"
}
]
}

10
.vscode/settings.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,10 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"search.exclude": {
"**/node_modules": true,
"bin": true,
"buildcache": true,
"coverage": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
}

Просмотреть файл

@ -1,3 +1,21 @@
[![Build Status](https://dev.azure.com/azure-public/azsdk/_apis/build/status/Azure.git-rest-api?branchName=master)](https://dev.azure.com/azure-public/azsdk/_build/latest?definitionId=33&branchName=master)
# Start
1. Install dependencies
```bash
npm install
```
2. Run
```bash
npm start # To run once
npm start:watch # To run and restart when there is a change
```
Run in vscode
Instead of `npm start` run `npm build:watch` and in vscode press `F5`
# Contributing # Contributing

Разница между файлами не показана из-за своего большого размера Загрузить разницу

18
config/jest.dev.config.js Normal file
Просмотреть файл

@ -0,0 +1,18 @@
// @ts-check
const mainConfig = require("../jest.config");
/** @type {jest.InitialOptions} */
const config = {
...mainConfig,
globals: {
"ts-jest": {
tsConfig: "tsconfig.json",
diagnostics: { warnOnly: true } // Make typescript show errors as warning while writing test. This is specially for noUnusedLocals which is always preventing test to run.
}
},
rootDir: "../",
verbose: false
};
module.exports = config;

Просмотреть файл

@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"exclude": ["node_modules", "bin", "test", "**/*spec.ts"]
}

24
jest.config.js Normal file
Просмотреть файл

@ -0,0 +1,24 @@
// @ts-check
/** @type {jest.InitialOptions} */
const config = {
transform: {
"^.+\\.ts$": "ts-jest",
},
moduleFileExtensions: ["ts", "js", "json", "node"],
moduleNameMapper: {},
collectCoverage: true,
collectCoverageFrom: ["src/**/*.ts", "!**/node_modules/**"],
coverageReporters: ["json", "lcov", "cobertura", "text", "html", "clover"],
coveragePathIgnorePatterns: ["/node_modules/", ".*/test/.*"],
globals: {
"ts-jest": {
tsConfig: "tsconfig.json",
},
},
testMatch: ["**/*.test.ts"],
verbose: true,
testEnvironment: "node",
};
module.exports = config;

6379
package-lock.json сгенерированный Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

47
package.json Normal file
Просмотреть файл

@ -0,0 +1,47 @@
{
"name": "git-rest-api",
"version": "1.0.0",
"description": "This project welcomes contributions and suggestions. Most contributions require you to agree to a\r Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\r the rights to use your contribution. For details, visit https://cla.microsoft.com.",
"main": "bin/main.js",
"scripts": {
"build": "tsc -p config/tsconfig.build.json",
"build:watch": "npm run -s build -- --watch",
"start": "npm run build && node ./bin/main.js",
"start:dev": "concurrently --handle-input \"wait-on bin/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
"start:debug": "nodemon --config nodemon-debug.json",
"test": "jest",
"lint": "tslint -p tsconfig.json",
"test:watch": "jest --watch --coverage:false --config ./config/jest.dev.config.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Azure/git-rest-api.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/Azure/git-rest-api/issues"
},
"homepage": "https://github.com/Azure/git-rest-api#readme",
"devDependencies": {
"@types/jest": "^24.0.13",
"concurrently": "^4.1.0",
"jest": "^24.8.0",
"prettier": "^1.17.1",
"ts-jest": "^24.0.2",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.4.5"
},
"dependencies": {
"@nestjs/common": "^6.2.0",
"@nestjs/core": "^6.2.0",
"@nestjs/platform-express": "^6.2.0",
"@types/node": "^12.0.2",
"class-validator": "^0.9.1",
"nodegit": "^0.24.3",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.5.2"
}
}

11
src/app.module.ts Normal file
Просмотреть файл

@ -0,0 +1,11 @@
import { Module } from "@nestjs/common";
import { AppController } from "./controllers";
import { AppService } from "./services";
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

Просмотреть файл

@ -0,0 +1,15 @@
import { Controller, Get } from "@nestjs/common";
import { AppService } from "../services";
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {
this.appService.getHello();
}
@Get()
public getHello(): string {
return this.appService.getHello();
}
}

Просмотреть файл

@ -0,0 +1,15 @@
import { HealthCheckController } from "./health-check.controller";
describe("HealthCheckController", () => {
let controller: HealthCheckController;
beforeEach(() => {
controller = new HealthCheckController();
});
describe("alive", () => {
it('should return alive"', async () => {
expect(await controller.getAlive()).toBe("alive");
});
});
});

Просмотреть файл

@ -0,0 +1,9 @@
import { Controller, Get } from "@nestjs/common";
@Controller("/health")
export class HealthCheckController {
@Get("/alive")
public async getAlive() {
return "alive";
}
}

2
src/controllers/index.ts Normal file
Просмотреть файл

@ -0,0 +1,2 @@
export * from "./app.controller";
export * from "./health-check/health-check.controller";

14
src/main.ts Normal file
Просмотреть файл

@ -0,0 +1,14 @@
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3009);
}
bootstrap().catch(error => {
// tslint:disable-next-line: no-console
console.error("Error in app", error);
process.exit(1);
});

0
src/models/index.ts Normal file
Просмотреть файл

Просмотреть файл

@ -0,0 +1,8 @@
import { Injectable } from "@nestjs/common";
@Injectable()
export class AppService {
public getHello(): string {
return "Hello World!";
}
}

1
src/services/index.ts Normal file
Просмотреть файл

@ -0,0 +1 @@
export * from "./app.service";

48
tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,48 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "bin",
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "incremental": true, /* Enable incremental compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
"incremental": true,
"tsBuildInfoFile": "./buildcache/backend.tsbuildinfo",
/* Additional Checks */
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
/* Source Map Options */
"sourceMap": true,
/* Experimental Options */
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}

43
tslint.json Normal file
Просмотреть файл

@ -0,0 +1,43 @@
{
"defaultSeverity": "error",
"extends": ["tslint:latest", "tslint-config-prettier", "tslint-plugin-prettier"],
"jsRules": {},
"rules": {
"file-name-casing": [true, "kebab-case"],
"no-unused-expression": [true, "allow-fast-null-checks"],
"interface-name": false,
"object-literal-sort-keys": false,
"no-object-literal-type-assertion": false,
"no-console": true,
"member-ordering": false,
"no-implicit-dependencies": [true, "dev"],
"prefer-conditional-expression": false,
"no-submodule-imports": false,
"no-default-export": true,
"prettier": [true, ".prettierrc.yml"],
"no-empty-interface": false,
"no-floating-promises": true, // No unawaited or caught promises(This could cause process exit in later version of node)
"ordered-imports": [
true,
{
"import-sources-order": "case-insensitive",
"named-imports-order": "lowercase-last",
"grouped-imports": true,
"groups": [
{ "match": "^\\..*$", "order": 20 }, // Have relative imports
{ "match": ".*", "order": 10 }
]
}
],
"ban": [
true,
{ "name": "fdescribe", "message": "Don't leave focus tests" },
{ "name": "fit", "message": "Don't leave focus tests" },
{ "name": "ftest", "message": "Don't leave focus tests" },
{ "name": ["describe", "only"], "message": "Don't leave focus tests" },
{ "name": ["it", "only"], "message": "Don't leave focus tests" },
{ "name": ["test", "only"], "message": "Don't leave focus tests" }
]
},
"rulesDirectory": []
}