๐ง WIP: This project has the objective of being a boilerplate for my new proejcts
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
What things you need to install the software and how to install them
1- Check if you have NodeJS installed
2- Install docker - we use docker for the development and test DB, never use dcoker's DB for production
A step by step series of examples that tell you how to get a development env running
Clone the repo
git clone https://github.com/guiaramos/ts-graphql-server.git
cd ts-graphql-serverGet it running
npm install
npm run db
npm start
Example of resolver
mutation Register($email: String!, $password: String!){
register(email: $email,password: $password)
}{
"data": {
"register": true
}
}This server has e2e and integration tests
I am still to create the e2e tests
No examples yet
The objective of the tests is to ensure that the resolvers are computing the expected data on DB and returning the correct output for the request
it('should register the user', async function() {
const { mutate } = testServer();
const response = await mutate({
mutation: REGISTER,
variables: MOCK_USER
});
expect(response?.data?.register).toBeTruthy();
});
it('should have hashed password', async function() {
const { password } = await User.findOneOrFail({
where: { email: MOCK_USER.email }
});
expect(password).not.toEqual(MOCK_USER.password);
});
it('should return error if user already exists', async function() {
const { mutate } = testServer();
const response = await mutate({
mutation: REGISTER,
variables: { email: 'test@test.com', password: 'qwer1234' }
});
const message = response?.errors;
expect(message ? message[0].message : 'no error message').toContain(
'duplicate key value violates unique constraint'
);
});There is no deployment for this project yet
- NodeJS - JavaScript runtime built on Chrome's V8 JavaScript engine.
- Typescript - A typed superset of JavaScript that compiles to plain JavaScript.
- Apollo Server - Spec-compliant GraphQL server
- Express - Fast, unopinionated, minimalist web framework
- TypeORM - TypeORM is an ORM that can run in NodeJS
- Jest - Delightful JavaScript Testing Framework
- ESLint - Pluggable JavaScript linter
- Prettier - Opinionated Code Formatter
- graphql-codegen - Generate code from schema and operations with a simple CLI
- ts-node-dev - Tweaked version of node-dev that uses ts-node under the hood.
- ts-jest - TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Guilherme Ramos - Initial work - guiaramos
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details