This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RAINCATCH-1131 - wfm-users module (#86)
* Git fixes for broken config * Documentation update * Static backbone for wfm-user-module * wfm user implementation * Removing grunt * Logger improvements * wfm-rest-api docs fixes * Improved error handling for api * Move users to demo-data * Demo application integration * Unit test coverage game * Ignore case for demo data * Improvements for error handling * Documentation * Api pattern - wrap response in object * Example application * Add types to allow stricter compiler options (#2) * Adding get handler * Docs improvements * Update types to lerna hoisted versions * Fix compile error
- Loading branch information
Showing
35 changed files
with
602 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# generated code | ||
src/**/*.js | ||
src/**/*.map | ||
test/**/*.js | ||
test/**/*.map | ||
coverage_report/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# wfm-user | ||
|
||
Module responsible for user operations required by all WFM modules. | ||
|
||
## RESTfull API | ||
|
||
### Filter | ||
|
||
> GET /?filter=name&limit=10 | ||
Retruns JSON array containing users | ||
```json | ||
{ | ||
"users": [] | ||
} | ||
``` | ||
|
||
#### Example | ||
|
||
http://localhost:8001/api/users?filter=a&limit=1 | ||
|
||
> Note: Default limit is 10 | ||
#### Errors | ||
|
||
Missing filter: `{status: 400 , code: 'InvalidFilter'}` | ||
|
||
### Get user by id | ||
|
||
> GET /:id | ||
Gets user by id | ||
|
||
#### Example | ||
|
||
http://localhost:8001/api/users/fhj3nf | ||
|
||
#### Errors | ||
|
||
Missing id `{status: 400 , code: 'InvalidID'}` | ||
|
||
## Implementing UserRepository | ||
|
||
In order for module to be able to fetch user data any implementations | ||
need to implement user repository class. | ||
|
||
See demo application integration or [example application](./example) for more details. | ||
|
||
## Relation to security module | ||
|
||
The main purpose of this module is to allow administrators to retrieve and manage mobile users. | ||
This data may come from different datasource than data from security module. | ||
This module should not be used to fech any user related details like user profile etc. | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## wfm-user example | ||
|
||
### Running example | ||
|
||
ts-node example/index.ts | ||
|
||
To test example execute in your console | ||
|
||
curl http://localhost:3000/api/users?filter=example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { getLogger } from '@raincatcher/logger'; | ||
import * as Bluebird from 'bluebird'; | ||
import * as express from 'express'; | ||
import * as path from 'path'; | ||
import { User, UserController, UsersRepository } from '../src/index'; | ||
|
||
const app = express(); | ||
|
||
const exampleUser: User = { id: 1, name: 'Example User', username: 'example' }; | ||
|
||
/** | ||
* Simplified example UsersRepository. | ||
* Implementation can fetch users from databases, LDAP etc. | ||
*/ | ||
class ExampleRepository implements UsersRepository { | ||
public getUser(id: string | number): Bluebird<User> { | ||
return Bluebird.resolve(exampleUser); | ||
} | ||
public retrieveUsers(filter: string, limit: number): Bluebird<User[]> { | ||
return Bluebird.resolve([exampleUser]); | ||
} | ||
} | ||
|
||
// Create repository | ||
const repository = new ExampleRepository(); | ||
// Create api | ||
const api = new UserController(repository); | ||
|
||
// Mount api into path | ||
app.use('/api/users', api.buildRouter()); | ||
|
||
app.use(function(err: any, req: express.Request, res: express.Response, next: any) { | ||
getLogger().error(err); | ||
res.status(500).send(err); | ||
}); | ||
|
||
app.listen(3000, function() { | ||
getLogger().info('Example auth app listening on port 3000'); | ||
}); |
Oops, something went wrong.