93 lines
2.5 KiB
Markdown
93 lines
2.5 KiB
Markdown
# loopback4-example-github
|
|
|
|
This LoopBack application is an example to connect to third party REST APIs, GitHub API.
|
|
|
|
It shows:
|
|
|
|
- how to define template and options in [REST connector datasource](./src/datasources/githubds.datasource.ts).
|
|
- how to traverse pages in the results in the [controller](./src/controllers/gh-query.controller.ts)
|
|
|
|
## Blog posts
|
|
|
|
I'll be creating a series of blog posts on how to create this end-to-end, i.e. from creating APIs in LoopBack application to frontend using React. Stay tuned!
|
|
|
|
- [Part 1: Creating Datasource to GitHub API](https://mobilediana.medium.com/building-an-end-to-end-application-with-loopback-react-js-7a22d726c35d)
|
|
- [Part 2: Creating Service Proxy](https://mobilediana.medium.com/building-an-end-to-end-application-with-loopback-react-js-part-2-creating-service-proxy-7ffac2bd7980)
|
|
- [Part 3: Pagination in GitHub API Results](https://mobilediana.medium.com/building-an-end-to-end-application-with-loopback-react-js-90cfd7a4813c#a270-8107da706e6f)
|
|
|
|
---
|
|
|
|
This application is generated using [LoopBack 4 CLI](https://loopback.io/doc/en/lb4/Command-line-interface.html) with the
|
|
[initial project layout](https://loopback.io/doc/en/lb4/Loopback-application-layout.html).
|
|
|
|
## Install dependencies
|
|
|
|
By default, dependencies were installed when this application was generated.
|
|
Whenever dependencies in `package.json` are changed, run the following command:
|
|
|
|
```sh
|
|
npm install
|
|
```
|
|
|
|
To only install resolved dependencies in `package-lock.json`:
|
|
|
|
```sh
|
|
npm ci
|
|
```
|
|
|
|
## Run the application
|
|
|
|
```sh
|
|
npm start
|
|
```
|
|
|
|
You can also run `node .` to skip the build step.
|
|
|
|
Open http://127.0.0.1:3000 in your browser.
|
|
|
|
## Rebuild the project
|
|
|
|
To incrementally build the project:
|
|
|
|
```sh
|
|
npm run build
|
|
```
|
|
|
|
To force a full build by cleaning up cached artifacts:
|
|
|
|
```sh
|
|
npm run rebuild
|
|
```
|
|
|
|
## Fix code style and formatting issues
|
|
|
|
```sh
|
|
npm run lint
|
|
```
|
|
|
|
To automatically fix such issues:
|
|
|
|
```sh
|
|
npm run lint:fix
|
|
```
|
|
|
|
## Other useful commands
|
|
|
|
- `npm run migrate`: Migrate database schemas for models
|
|
- `npm run openapi-spec`: Generate OpenAPI spec into a file
|
|
- `npm run docker:build`: Build a Docker image for this application
|
|
- `npm run docker:run`: Run this application inside a Docker container
|
|
|
|
## Tests
|
|
|
|
```sh
|
|
npm test
|
|
```
|
|
|
|
## What's next
|
|
|
|
Please check out [LoopBack 4 documentation](https://loopback.io/doc/en/lb4/) to
|
|
understand how you can continue to add features to this application.
|
|
|
|
[-@2x.png>)](http://loopback.io/)
|