Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/brkn/typeorm-express-example

Typeorm express example
https://github.com/brkn/typeorm-express-example

express heroku postgresql typeorm typescipt

Last synced: 29 days ago
JSON representation

Typeorm express example

Awesome Lists containing this project

README

        

# Typeorm Express Example

## Endpoints

- `GET /leaderboard`

returns

```json
[
{
"user_id": "995ea63a-5ecc-4f18-b271-5f46f661c975",
"display_name": "DN_995ea63a-5ecc-4f18-b271-5f46f661c975",
"country": "fr",
"points": 3493,
"rank": "1"
},
{
"user_id": "0ac1a298-db42-4881-8f2b-3eff152f4609",
"display_name": "DN_0ac1a298-db42-4881-8f2b-3eff152f4609",
"country": "ca",
"points": 3475,
"rank": "2"
},
{
"user_id": "2b945048-8d68-4992-8089-6cf46bf27dc9",
"display_name": "DN_2b945048-8d68-4992-8089-6cf46bf27dc9",
"country": "fr",
"points": 1005,
"rank": "499"
}
]
```

- `GET /leaderboard/`

ex: `/leaderboard/fr` returns

```json
[
{
"user_id": "995ea63a-5ecc-4f18-b271-5f46f661c975",
"display_name": "DN_995ea63a-5ecc-4f18-b271-5f46f661c975",
"country": "fr",
"points": 3493,
"rank": "1"
},
{
"user_id": "2b945048-8d68-4992-8089-6cf46bf27dc9",
"display_name": "DN_2b945048-8d68-4992-8089-6cf46bf27dc9",
"country": "fr",
"points": 1005,
"rank": "499"
}
]
```

- `POST /user/create`

ex payload:

```json
{
"user_id": "string",
"display_name": "string",
"country": "tr",
"points": 123.456
}
```

Note: Sending a ranking inside the payload is not allowed. This is intentional.

- `POST /user/create/batch`

ex payload:

```json
[
{
"user_id": "string",
"display_name": "string",
"country": "string",
"points": 123.456
},
{
"user_id": "string",
"display_name": "string",
"country": "string",
"points": 123.456
}
]
```

- `POST /user/create/batch-random`

ex payload:

```json
{
"count": 123456
}
```

- `GET /user/profile/`

ex response:

```json
{
"user_id": "995ea63a-5ecc-4f18-b271-5f46f661c975",
"display_name": "DN_995ea63a-5ecc-4f18-b271-5f46f661c975",
"country": "fr",
"points": 3493,
"rank": "1"
}
```

- `POST /score/submit`

ex payload:

```json
{
"user_id": "string",
"timestamp": "string",
"score_worth": 123.345
}
```

## Local development

1. Create dotenv file

- `cp .env.dev .env`

2. Install dependencies

- `yarn`

3. Run migrations

- `yarn typeorm migrations:run`

4. Run server
- `yarn dev`