initial commit

pull/1/head
leonnicolas 4 years ago
commit 8711aa3b38
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

2
.gitignore vendored

@ -0,0 +1,2 @@
node_modules
dist

@ -0,0 +1,14 @@
FROM node
WORKDIR /
COPY ./src /src
COPY ./package*.json ./
COPY ./gulpfile.js ./tsconfig.json ./tslint.json ./
RUN npm install
RUN npm install -g gulp
RUN npm install gulp
RUN gulp
EXPOSE 4000
CMD ["npm", "start"]

@ -0,0 +1,29 @@
# API-server
Apollo server written in typescript that handles business logic.
## Usage
### Docker
```bash
docker build -t <image name> .
docker run --rm -p 4000:4000 <image name>
```
The Dockerfile is pretty stupid and could produce a smaller image, e.g. with multistage build.
### NPM and gulp
Install gulp if not installed
```bash
npm -g gulp
```
```bash
npm install
gulp
npm start
```
### For Development
```bash
gulp watch
```
to compile in watch mode. And in another terminal run
```bash
npm start
```
The later command uses nodemon. I am sure you can so this with gulp as well.

@ -0,0 +1,61 @@
const {src, dest, watch, series, task} = require('gulp');
const ts = require('gulp-typescript');
const del = require('delete');
var tslint = require("gulp-tslint");
/**
* Clears the dist folder by deleting all files inside.
* @param cb
*/
function clearDist(cb) {
del('dist/*', cb);
}
/**
* Typescript compilation task.
* @returns {*}
*/
function compileTypescript() {
let tsProject = ts.createProject('tsconfig.json');
let tsResult = tsProject.src().pipe(tsProject());
return tsResult
//.pipe(minify())
.pipe(dest('dist'));
}
/**
* Task for moving all remaining file from source to dist that don't need procession.
* @returns {*}
*/
function moveRemaining() {
return src(['src/**/*', '!src/**/*.ts'])
.pipe(dest('dist'));
}
function runTSlint(){
src('src/**/*.ts')
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report())
}
task("tslint", () =>
src('src/**/*.ts')
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report())
);
task('default', series(clearDist, compileTypescript, moveRemaining));
task('watch', () => {
watch('**/*.ts', compileTypescript);
watch(['src/**/*', '!src/**/*.ts'], moveRemaining());
});
task('watchtslint', () => {
watch('**/*.ts', runTSlint);
watch('**/*.ts', compileTypescript);
watch(['src/**/*', '!src/**/*.ts'], moveRemaining());
});

5556
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,27 @@
{
"name": "graphql-server-flotte-ts",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon dist/index.js",
"start:ci": "node dist/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"delete": "^1.1.0",
"gulp": "^4.0.2",
"gulp-tslint": "^8.1.4",
"gulp-typescript": "^6.0.0-alpha.1",
"nodemon": "^2.0.4",
"tslint": "^6.1.3",
"typescript": "^4.0.2"
},
"dependencies": {
"apollo-server": "^2.17.0",
"graphql": "^15.3.0"
}
}

@ -0,0 +1,11 @@
// tslint:disable: no-console
import { ApolloServer } from 'apollo-server';
// import resolvers from './resolvers';
import typeDefs from './schema/type-defs';
const server = new ApolloServer({ typeDefs });
server.listen()
.then(({ url }) => console.log(`Server ready at ${url}.. `));

@ -0,0 +1,10 @@
import { gql } from 'apollo-server';
export default gql`
type Query {
"""
Test Message.
"""
testMessage: String!
}
`;

@ -0,0 +1,22 @@
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"outDir": "./dist",
"sourceMap": true,
"target": "es2018",
"allowJs": true,
"moduleResolution": "node",
"module": "commonjs",
"esModuleInterop": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}

@ -0,0 +1,40 @@
{
"extends": "tslint:recommended",
"rulesDirectory": [],
"rules": {
"max-line-length": {
"options": [120]
},
"new-parens": true,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-consecutive-blank-lines": false,
"cyclomatic-complexity": true,
"brace-style": "1tbs",
"semicolon": true,
"indent": [true, "spaces", 4],
"no-shadowed-variable": true,
"no-console": {
"severity": "warning",
"options": ["debug", "info", "log", "time", "timeEnd", "trace"]
},
"no-namespace": false,
"no-internal-module": false,
"max-classes-per-file": false,
"no-var-requires": false,
"jsdoc-format": [true, "check-multiline-start"],
"completed-docs": [true, "classes", "enums", "methods", {
"properties": {
"privacies": "all",
"locations": "instance"
}
}]
},
"jsRules": {
"max-line-length": {
"options": [120]
}
}
}
Loading…
Cancel
Save