An open API service indexing awesome lists of open source software.

https://github.com/bniedermeyer/json-server-schematics

Angular schematics for adding json-server(https://github.com/typicode/json-server) to your projects.
https://github.com/bniedermeyer/json-server-schematics

angular json-server schematics

Last synced: 7 months ago
JSON representation

Angular schematics for adding json-server(https://github.com/typicode/json-server) to your projects.

Awesome Lists containing this project

README

          

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

# JSON-SERVER-SCHEMATICS

This repository is a basic Schematic implementation that serves to quickly add and configure [json-server](http://commitizen.github.io/cz-cli/) to an Angular project.

### What it does

The schematic does four things:

1. Installs json-server as a dev dependency into your project
2. Creates a directory for your json server files with example `db.json` and `routes.json` files
3. Add a proxy configuration to your Angular project so that http requrests to `/api/*` will be pointed to json server
4. Adds convienience scripts to the project's `package.json` to start and serve your project with json-server or run it on its own.

## Getting Started

Call the schematic with the Angular cli and follow the prompt to tell the Schematic where to create your json-server files.

```bash
ng add json-server-schematics
```

That's all you need to do!

## Development

### Testing

To test locally, install `@angular-devkit/schematics-cli` globally and use the `schematics` command line tool. That tool acts the same as the `generate` command of the Angular CLI, but also has a debug mode.

Check the documentation with

```bash
schematics --help
```

Additionally this project has a sandbox Angular project for ease of use when developing locally. To use the Schematic in the project you must:

1. build the Schematic
2. link the Schematic to the sandbox project
3. navigate into the sandbox project and call the schematic.
4. remove created files generated by the schematic between runs

There are a number of convinience scripts included that assist in this process.

```bash
# build the project
npm run build

# link the schematic
npm run link:schematic

# execute the schematic in the sandbox
npm test

# clean the sanddbox after the test before running again
npm run clean
```

### Publishing

To publish, simply do:

```bash
npm run build
npm publish
```

That's it!