This project can be used as a template for a web service. It contains:
- backend generator used to speed up development process
- an example blog project containing users, profile images and blog posts
- an interactive graphql console for exploring the API
Technology stack includes: javascript-node-express-graphql-typeorm-type-graphql
npm run generate
Backend is mostly generated from specification file src/data/model.er
.
ER (entities' relations) file is a way to define project's relations and fields for relations. You can open (and edit) the file for further info.
The project currently implements a backend for simple blogging engine containing users, blog posts and files. It allows users to register and manage their profile info, profile image and post blog posts. Email login, facebook login and google login are also implemented.
config.ts
contains the info about all env variables required for setting up project for social login and database connection
For every relation, the following files are generated in the data
directory:
- model
which contains all fields, relations and update method
- `auth` which defines permissions for every one of CRUD operations per entity
- `enum` which contains all enums mentioned in the ER file
- `field-resolver` for custom graphql resolvers
- `resolver` for automatically generated CRUD operations
- `inputs/CreateInput` for input used in CREATE operations
- `inputs/NestedInput` for input used in nested UPDATE operations (used to update relations)
- `inputs/EditInput` for input used in regular UPDATE operations
Most of these files can be edited by adding code within the existing // <keep-*> tags.
npm start
npm test
npm run lint
npm run proxy
node src
npm run db:migration:create
npm run db:migration:generate
npm run db:migration:up
Run npm start
and open your graphql console at http://localhost:5001/playground
so you can try out the backend there.
To be able to use automatic authentication via cookies, set "request.credentials" to "include" in playground console settings.
When application is run for the first time, administrator user [email protected]
is created.
You can login by going to http://localhost:5001/playground
and executing this mutation:
mutation {
emailLogin(email: "[email protected]", password: "password") {
token
}
}