- have node installed (tested on v12 & v13)
- have mongodb up and running
- have nodemon installed globally
npm i -g nodemon - have the angular cli installed globally
npm i -g @angular/cli
- navigate to
api/in your terminal of choice - install dependencies by running
npm i(takes a while) - run the api (restarts on code changes):
npm start
(for the request types, see api/insomnia/)
- install the cli:
npm i -g @angular/cli - navigate to
web/in your terminal of choice - install dependencies by running
npm i(takes a while) - compile and serve:
ng serve(may take a long time at first start)
API:
Start in server.js and find the referenced files, the comments will guide you. Example API calls can be seen in api/insomnia/, you can also install insomnia and import api/insomnia/insomnia-workspace.json to try the requests out for yourself.
The lists/ and to-dos/ directories are what I call resolver blocks, they consist of
connectors.jscontaining the structure of the objects this block will read/writeschema.graphqlto define the types, queries, mutations, etc. used by graphqlresolvers.jscontains the logic behind the schemaschema.jscombines schema and resolvers into an executable schema that can be accessed via the API
Web interface:
Start in the src/app/ directory, the non-default .ts files have comments, if have never seen an angular project, look here. You probably can't understand the code in this repo, if you have never built an angular app before.
- nodemon is not suitable for production use, install pm2 globally
npm i -g nodemon - run the server via
npm run prod - to see running services
pm2 list - to stop the service again
pm2 stop <id>(replace<id>with the service id from the previous step) - edit the cors rules in
server.jsto allow requests from the web interface - you might also want to change the
DB_URLconstant inglobals.jsto use a remote mongodb instance
- edit the
uriconstant insrc/app/graphql.module.tsto point to your api endpoint on your server - run
ng build --prod(may take a really long time) - place the contents of the newly created
dist/website/directory on your web root (var/www/html/on apache2) - don't forget to configure the server in a way, that redirects all requests to the interface to
index.htmlsince this file includes the scripts that do all the routing - there should be a
.htaccessindist/, it can be used to redirect on an apache2 server (for nginx google:nginx angular😅)
I copied/renamed the lists/to-dos directory to make my own schema an it will not work.
- Edit the line with the
readFile()call insideschema.jsand change the path to the name of your new/renamed folder. - Also you might have forgotten to include the new schema in
global-schema.js, use the other imports as your template and add the new schema to theschemasarray inmergeSchemas()