diff options
author | ilyayudovin <46264063+ilyayudovin@users.noreply.github.com> | 2020-06-09 13:29:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 13:29:16 +0300 |
commit | abe7c3220c40031b9adecf9b27ab7141b7d3f736 (patch) | |
tree | 063c275cdf64d5a30cf81e993721ac1fc8dc672c | |
parent | 977992eb70a0ca3b702e116b628d37ac75e667d1 (diff) | |
parent | 3fb48244900333f5085ffa2058a242aacec9c61c (diff) | |
download | which-api-abe7c3220c40031b9adecf9b27ab7141b7d3f736.tar.gz |
Merge pull request #1 from eug-vs/user-service
Create user service
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | UserService.ts | 22 | ||||
-rw-r--r-- | app.ts | 12 | ||||
-rw-r--r-- | package.json | 12 |
4 files changed, 44 insertions, 3 deletions
@@ -1 +1,2 @@ /node_modules +/.idea
\ No newline at end of file diff --git a/UserService.ts b/UserService.ts new file mode 100644 index 0000000..0cbb649 --- /dev/null +++ b/UserService.ts @@ -0,0 +1,22 @@ +interface User { + info : { + name: string; + age: number; + nationality: string; + sex: string; + } +} + +export class UserService { + users: User[] = []; + + async find (){ + return this.users; + } + + async create(data: Pick<User, 'info'>){ + const user: User = {...data}; + this.users.push(user); + return user; + } +}
\ No newline at end of file @@ -4,6 +4,7 @@ import express from '@feathersjs/express'; import socketio from '@feathersjs/socketio'; import { PollService } from './PollService'; +import {UserService} from "./UserService"; const app = express(feathers()); @@ -15,7 +16,7 @@ app.configure(socketio()); app.use(express.errorHandler()); app.use('/polls', new PollService()); - +app.use('/users', new UserService()); // Add any new real-time connection to the `everybody` channel app.on('connection', connection => @@ -43,3 +44,12 @@ app.service('polls').create({ } } }); + +app.service('users').create({ + info: { + name: 'John Doe', + age: 20, + nationality: 'Belarus', + sex: 'male' + } +}); diff --git a/package.json b/package.json index 8a8afee..758cb99 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "@oneflow/which-api", "version": "1.0.0", - "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -14,5 +13,14 @@ "@feathersjs/feathers": "^4.5.3", "@feathersjs/socketio": "^4.5.4", "@feathersjs/transport-commons": "^4.5.3" - } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/eug-vs/which-api.git" + }, + "bugs": { + "url": "https://github.com/eug-vs/which-api/issues" + }, + "homepage": "https://github.com/eug-vs/which-api#readme", + "description": "" } |