File tree Expand file tree Collapse file tree 4 files changed +44
-3
lines changed Expand file tree Collapse file tree 4 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 1
1
/node_modules
2
+ /.idea
Original file line number Diff line number Diff line change
1
+ interface User {
2
+ info : {
3
+ name : string ;
4
+ age : number ;
5
+ nationality : string ;
6
+ sex : string ;
7
+ }
8
+ }
9
+
10
+ export class UserService {
11
+ users : User [ ] = [ ] ;
12
+
13
+ async find ( ) {
14
+ return this . users ;
15
+ }
16
+
17
+ async create ( data : Pick < User , 'info' > ) {
18
+ const user : User = { ...data } ;
19
+ this . users . push ( user ) ;
20
+ return user ;
21
+ }
22
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import express from '@feathersjs/express';
4
4
import socketio from '@feathersjs/socketio' ;
5
5
6
6
import { PollService } from './PollService' ;
7
+ import { UserService } from "./UserService" ;
7
8
8
9
const app = express ( feathers ( ) ) ;
9
10
@@ -15,7 +16,7 @@ app.configure(socketio());
15
16
app . use ( express . errorHandler ( ) ) ;
16
17
17
18
app . use ( '/polls' , new PollService ( ) ) ;
18
-
19
+ app . use ( '/users' , new UserService ( ) ) ;
19
20
20
21
// Add any new real-time connection to the `everybody` channel
21
22
app . on ( 'connection' , connection =>
@@ -43,3 +44,12 @@ app.service('polls').create({
43
44
}
44
45
}
45
46
} ) ;
47
+
48
+ app . service ( 'users' ) . create ( {
49
+ info : {
50
+ name : 'John Doe' ,
51
+ age : 20 ,
52
+ nationality : 'Belarus' ,
53
+ sex : 'male'
54
+ }
55
+ } ) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @oneflow/which-api" ,
3
3
"version" : " 1.0.0" ,
4
- "description" : " " ,
5
4
"main" : " index.js" ,
6
5
"scripts" : {
7
6
"test" : " echo \" Error: no test specified\" && exit 1"
14
13
"@feathersjs/feathers" : " ^4.5.3" ,
15
14
"@feathersjs/socketio" : " ^4.5.4" ,
16
15
"@feathersjs/transport-commons" : " ^4.5.3"
17
- }
16
+ },
17
+ "repository" : {
18
+ "type" : " git" ,
19
+ "url" : " git+https://github.com/eug-vs/which-api.git"
20
+ },
21
+ "bugs" : {
22
+ "url" : " https://github.com/eug-vs/which-api/issues"
23
+ },
24
+ "homepage" : " https://github.com/eug-vs/which-api#readme" ,
25
+ "description" : " "
18
26
}
You can’t perform that action at this time.
0 commit comments