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

https://github.com/zoltan-nz/koa-ts-contacts-app

REST API demo application with TypeScript, Koa.js
https://github.com/zoltan-nz/koa-ts-contacts-app

koa2 koajs nodejs typescript

Last synced: 3 months ago
JSON representation

REST API demo application with TypeScript, Koa.js

Awesome Lists containing this project

README

          

# koa-ts-contacts-app

Building a simple contact management REST API using Node.js, TypeScript, Koa.js.

**Requirements**

* MVC pattern
* Dependency Injection
* Authentication
* Database, MongoDB support, migration
* Models: Contact, Category
* REST API, Json interface
* Unit tests

**Useful links:**

* [Article 1](http://mherman.org/blog/2017/08/23/building-a-restful-api-with-koa-and-postgres/)
* [Article 2](https://devdactic.com/restful-api-user-authentication-1/)

**Packages**

Build:

* TypeScript
* TSLint
* ts-node
* chockidar
* concurrently

Using direct command line tools with npm script.

Test:

* Jest (or Mocha)

Core:

* Koa

Database:

* Sequalizer
* Mongoose

Authentication

* Passport?

**Requirements**

Data models

* contact
* category
* user

```
Contact
- id
- name (string)
- email (string)
- category (belongsTo)

Category
- id
- name
- contacts (hasMany)

User
- id
- username
- password
- email
```

*Resource endpoints*

| path | method | |
|:--- |:--- | --- |
|`/api/categories`| GET | list all record |
|`/api/categories`| POST | create a new category record |
|`/api/categories/:id`| GET | get the individual record |
|`/api/categories/:id`| PUT | update the whole record |
|`/api/categories/:id`| DELETE | get the individual record |
|`/api/contacts`| GET |
|`/api/contacts`| POST|
|`/api/contacts/:id`| GET |
|`/api/contacts/:id`| PUT |
|`/api/contacts/:id`| DELETE|

*Authentication*

Following Passport.js patterns: http://www.passportjs.org/docs/authenticate/

## Changelog

* Create `/api/categories` route
* Add test
* Add implementation

## Other Notes

* Investigating RESTyped: https://github.com/rawrmaan/restyped
* [Article](https://blog.falcross.com/introducing-restyped-end-to-end-typing-for-rest-apis-with-typescript/)