Skip to content

Commit cc693c4

Browse files
committed
initial commit
0 parents  commit cc693c4

File tree

16 files changed

+15614
-0
lines changed

16 files changed

+15614
-0
lines changed

client/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw*

client/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# client
2+
3+
## Project setup
4+
```
5+
npm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
npm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
npm run build
16+
```
17+
18+
### Run your tests
19+
```
20+
npm run test
21+
```
22+
23+
### Lints and fixes files
24+
```
25+
npm run lint
26+
```

client/babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/app'
4+
]
5+
}

client/package-lock.json

Lines changed: 12312 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "client",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"axios": "^0.18.0",
12+
"vue": "^2.5.17"
13+
},
14+
"devDependencies": {
15+
"@vue/cli-plugin-babel": "^3.0.5",
16+
"@vue/cli-plugin-eslint": "^3.0.5",
17+
"@vue/cli-service": "^3.0.5",
18+
"vue-template-compiler": "^2.5.17"
19+
},
20+
"eslintConfig": {
21+
"root": true,
22+
"env": {
23+
"node": true
24+
},
25+
"extends": [
26+
"plugin:vue/essential",
27+
"eslint:recommended"
28+
],
29+
"rules": {},
30+
"parserOptions": {
31+
"parser": "babel-eslint"
32+
}
33+
},
34+
"postcss": {
35+
"plugins": {
36+
"autoprefixer": {}
37+
}
38+
},
39+
"browserslist": [
40+
"> 1%",
41+
"last 2 versions",
42+
"not ie <= 8"
43+
]
44+
}

client/public/favicon.ico

1.12 KB
Binary file not shown.

client/public/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title>client</title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<!-- built files will be auto injected -->
16+
</body>
17+
</html>

client/src/App.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<div id="app">
3+
<img alt="Vue logo" src="./assets/logo.png">
4+
<PostComponent/>
5+
</div>
6+
</template>
7+
8+
<script>
9+
import PostComponent from './components/PostComponent'
10+
11+
export default {
12+
name: 'app',
13+
components: {
14+
PostComponent
15+
}
16+
}
17+
</script>
18+
19+
<style>
20+
#app {
21+
font-family: 'Avenir', Helvetica, Arial, sans-serif;
22+
-webkit-font-smoothing: antialiased;
23+
-moz-osx-font-smoothing: grayscale;
24+
text-align: center;
25+
color: #2c3e50;
26+
margin-top: 60px;
27+
}
28+
</style>

client/src/PostService.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import axios from 'axios';
2+
const url = 'http://localhost:5000/api/post';
3+
class PostService {
4+
static getPosts() {
5+
return new Promise(async (resolve, reject) => {
6+
try {
7+
const res = await axios.get(url);
8+
const data = res.data;
9+
resolve(
10+
data.map(post => ({
11+
...post,
12+
createdAt: new Date(post.createdAt)
13+
}))
14+
)
15+
} catch (err) {
16+
reject(err);
17+
}
18+
})
19+
}
20+
// creat post
21+
static insertPost(text) {
22+
return axios.post(url, {
23+
text
24+
});
25+
}
26+
//delete post
27+
static deletePost(id) {
28+
return axios.delete(`${url}${id}`);
29+
}
30+
}
31+
export default PostService;

client/src/assets/logo.png

6.69 KB
Loading

0 commit comments

Comments
 (0)