Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
App et archi Web TP 2020
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
antoine.blancy
App et archi Web TP 2020
Commits
4953ecb9
Commit
4953ecb9
authored
3 years ago
by
antoine.blancy
Browse files
Options
Downloads
Patches
Plain Diff
body no longer empty
parent
6d4753d5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
backend/blabla.rest
+11
-0
11 additions, 0 deletions
backend/blabla.rest
backend/modules/data.json
+1
-45
1 addition, 45 deletions
backend/modules/data.json
backend/modules/dbInterface.js
+2
-2
2 additions, 2 deletions
backend/modules/dbInterface.js
backend/server.js
+14
-3
14 additions, 3 deletions
backend/server.js
with
28 additions
and
50 deletions
backend/blabla.rest
0 → 100644
+
11
−
0
View file @
4953ecb9
GET http://localhost:8080/api/v1/list/features/antwan
###
POST http://localhost:8080/api/v1/list/features/
content-type: application/json
{
"userName": "antwan",
"elementId": "bruh"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/modules/data.json
+
1
−
45
View file @
4953ecb9
{
"antwan"
:
{
"spellList"
:[
"blink"
,
"dimension-door"
,
"reverse-gravity"
],
"monsterList"
:[
],
"featureList"
:[
]
},
"xioshiva"
:
{
"spellList"
:[
"animal-shapes"
,
"confusion"
],
"monsterList"
:[
],
"featureList"
:[
]
},
"user"
:
{
"spellList"
:[
"entangle"
,
"flesh-to-stone"
,
"haste"
],
"monsterList"
:[
],
"featureList"
:[
]
}
}
\ No newline at end of file
{
"antwan"
:{
"spellList"
:[
"blink"
,
"dimension-door"
,
"reverse-gravity"
],
"monsterList"
:[],
"featureList"
:[
"bruh"
]},
"xioshiva"
:{
"spellList"
:[
"animal-shapes"
,
"confusion"
],
"monsterList"
:[],
"featureList"
:[]},
"user"
:{
"spellList"
:[
"entangle"
,
"flesh-to-stone"
,
"haste"
],
"monsterList"
:[],
"featureList"
:[]}}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/modules/dbInterface.js
+
2
−
2
View file @
4953ecb9
...
...
@@ -37,8 +37,8 @@ function writeMonsterList(userName, monsterList){
function
writeFeatureList
(
userName
,
featureList
){
let
file
=
fs
.
readFileSync
(
'
modules/data.json
'
,
'
utf-8
'
);
let
fileData
=
JSON
.
parse
(
file
.
toString
());
fileData
[
user
n
ame
].
featureList
=
featureList
;
fs
.
writeFileSync
(
'
modules/data.json
'
,
fileData
);
fileData
[
user
N
ame
].
featureList
=
featureList
;
fs
.
writeFileSync
(
'
modules/data.json
'
,
JSON
.
stringify
(
fileData
)
)
;
}
module
.
exports
=
{
readSpellList
,
readMonsterList
,
readFeatureList
,
...
...
This diff is collapsed.
Click to expand it.
backend/server.js
+
14
−
3
View file @
4953ecb9
...
...
@@ -3,6 +3,13 @@ const express = require("express");
const
path
=
require
(
"
path
"
);
const
app
=
express
();
var
bodyParser
=
require
(
'
body-parser
'
);
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
const
db
=
require
(
'
./modules/dbInterface.js
'
);
const
auth
=
require
(
'
./modules/auth.js
'
);
...
...
@@ -12,6 +19,8 @@ const lst = require('./modules/list.js');
app
.
use
(
"
/static
"
,
express
.
static
(
path
.
resolve
(
__dirname
,
"
../frontend
"
,
"
static
"
)));
//Tout les autres chemins vont rediriger vers index.html pour créer une Single Page Application
lst
.
addFeature
(
"
antwan
"
,
"
archdruid
"
);
app
.
get
(
"
/api/v1/list/spells/:userName
"
,
(
req
,
res
)
=>
{
if
(
auth
.
doesUserExist
(
req
.
params
.
userName
)){
res
.
json
(
lst
.
getSpellList
(
req
.
params
.
userName
));
...
...
@@ -37,10 +46,12 @@ app.get("/api/v1/list/features/:userName", (req, res) => {
});
app
.
post
(
"
/api/v1/list/features/:userName/:featureId
"
,
(
req
,
res
)
=>
{
if
(
auth
.
doesUserExist
(
req
.
params
.
userName
)){
lst
.
addFeature
(
req
.
params
.
userName
)
app
.
post
(
"
/api/v1/list/features/
"
,
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
);
if
(
auth
.
doesUserExist
(
req
.
body
[
"
userName
"
])){
lst
.
addFeature
(
req
.
body
[
"
userName
"
],
req
.
body
[
"
elementId
"
]
);
res
.
json
(
lst
.
getFeatureList
);
res
.
status
(
200
).
end
();
}
else
{
res
.
status
(
422
).
end
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment