aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilyayudovin <46264063+ilyayudovin@users.noreply.github.com>2020-06-09 13:29:16 +0300
committerGitHub <noreply@github.com>2020-06-09 13:29:16 +0300
commitabe7c3220c40031b9adecf9b27ab7141b7d3f736 (patch)
tree063c275cdf64d5a30cf81e993721ac1fc8dc672c
parent977992eb70a0ca3b702e116b628d37ac75e667d1 (diff)
parent3fb48244900333f5085ffa2058a242aacec9c61c (diff)
downloadwhich-api-abe7c3220c40031b9adecf9b27ab7141b7d3f736.tar.gz
Merge pull request #1 from eug-vs/user-service
Create user service
-rw-r--r--.gitignore1
-rw-r--r--UserService.ts22
-rw-r--r--app.ts12
-rw-r--r--package.json12
4 files changed, 44 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 07e6e47..479880f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/app.ts b/app.ts
index 7607537..4a60eb8 100644
--- a/app.ts
+++ b/app.ts
@@ -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": ""
}