Skip to content

Commit abe7c32

Browse files
authored
Merge pull request #1 from eug-vs/user-service
Create user service
2 parents 977992e + 3fb4824 commit abe7c32

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/node_modules
2+
/.idea

UserService.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

app.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import express from '@feathersjs/express';
44
import socketio from '@feathersjs/socketio';
55

66
import { PollService } from './PollService';
7+
import {UserService} from "./UserService";
78

89
const app = express(feathers());
910

@@ -15,7 +16,7 @@ app.configure(socketio());
1516
app.use(express.errorHandler());
1617

1718
app.use('/polls', new PollService());
18-
19+
app.use('/users', new UserService());
1920

2021
// Add any new real-time connection to the `everybody` channel
2122
app.on('connection', connection =>
@@ -43,3 +44,12 @@ app.service('polls').create({
4344
}
4445
}
4546
});
47+
48+
app.service('users').create({
49+
info: {
50+
name: 'John Doe',
51+
age: 20,
52+
nationality: 'Belarus',
53+
sex: 'male'
54+
}
55+
});

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@oneflow/which-api",
33
"version": "1.0.0",
4-
"description": "",
54
"main": "index.js",
65
"scripts": {
76
"test": "echo \"Error: no test specified\" && exit 1"
@@ -14,5 +13,14 @@
1413
"@feathersjs/feathers": "^4.5.3",
1514
"@feathersjs/socketio": "^4.5.4",
1615
"@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": ""
1826
}

0 commit comments

Comments
 (0)