generated from WildCodeSchool/create-js-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from WildCodeSchool-2023-09/dev
BIG PR VERS MAIN : Principalement connexion BACK au FRONT Profil
- Loading branch information
Showing
67 changed files
with
3,198 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const tables = require("../tables"); | ||
|
||
const browse = async (req, res) => { | ||
try { | ||
const result = await tables.admin.readAll(); | ||
result.forEach((e) => delete e.password); | ||
res.json(result); | ||
} catch (err) { | ||
res.status(400).json({ error: err.message }); | ||
} | ||
}; | ||
|
||
const destroy = async (req, res, next) => { | ||
try { | ||
const { id } = req.params; | ||
const result = await tables.player.delete(id); | ||
|
||
if (result.affectedRows === 0) { | ||
res.status(404).send("id pas trouvée"); | ||
} else { | ||
res.status(200).send(`Le player ayant l'id: ${id} a bien été supprimée`); | ||
} | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
browse, | ||
destroy, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const tables = require("../tables"); | ||
|
||
const browse = async (req, res, next) => { | ||
try { | ||
const amis = await tables.amis.readAll(); | ||
|
||
res.json(amis); | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
const findById = async (req, res, next) => { | ||
try { | ||
const amis = await tables.amis.read(req.params.id); | ||
|
||
if (!amis) { | ||
res.sendStatus(404); | ||
} else { | ||
res.json(amis); | ||
} | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
const edit = async (req, res, next) => { | ||
try { | ||
const amis = await tables.amis.update(req.body); | ||
res.json(amis); | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
browse, | ||
findById, | ||
edit, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.