# Typeorm-Server

> Inspired by json-server.

## Install

global install

```bash
npm i -g ts-node @luics/typeorm-server
```

local install

```bash
npm i -D ts-node @luics/typeorm-server
```

## Cli use

global

```bash
typeorm-server --config "typeorm-server.json"
```

npm script

```bash
npx typeorm-server --config "typeorm-server.json"
```

`typeorm-server.json` sample:

```json
{
  "typeorm": {
    "host": "localhost",
    "port": 3306,
    "username": "test",
    "password": "test",
    "database": "test",
    "synchronize": false,
    "logging": false,
    "entities": ["path/to/entity/*.entity.{ts,js}"]
  },
  "schema": "path/to/entity/schema.json"
}
```

full doc see [TypeormServerConfig](./src/util.ts)

## Programmatic use

```ts
const app = express();
app.use(express.text({ type: '*/*' }));
app.use(cors({ origin: true, credentials: true }));
app.get('/', (_req, res) => res.json({}));
await useTypeormServerRoutersAsync(app, config, prefix);
```
