Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
final-exam
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nawasan Wisitsingkhon
final-exam
Commits
249022e7
Commit
249022e7
authored
Oct 01, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create: products api;
parent
4f5be806
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
ProductController.js
app/controllers/ProductController.js
+14
-4
web.js
app/routes/web.js
+2
-0
No files found.
app/controllers/ProductController.js
View file @
249022e7
import
{
Request
,
Response
}
from
"express"
;
import
db
from
"../models/prismaClient"
;
const
ProductController
=
{
/**
*
* @param {Request} req
* @param {Response} res
*/
async
index
(
req
,
res
)
{
let
product
=
await
db
.
product
.
findMany
();
await
db
.
$disconnect
()
res
.
json
(
product
)
},
};
}
export
default
ProductController
;
\ No newline at end of file
export
default
ProductController
;
app/routes/web.js
View file @
249022e7
...
...
@@ -4,6 +4,7 @@ import UserController from "../controllers/UserController";
import
adminRouter
from
"./admin"
;
import
{
JwtAdminMiddleware
}
from
"./middleware"
;
import
CategoryController
from
"../controllers/CategoryController"
;
import
ProductController
from
"../controllers/ProductController"
;
const
route
=
express
.
Router
();
route
.
use
(
"/admin/"
,
JwtAdminMiddleware
,
adminRouter
);
...
...
@@ -12,5 +13,6 @@ route.get("/user", UserController.index);
route
.
post
(
"/user/auth"
,
UserController
.
login
);
route
.
post
(
"/user"
,
UserController
.
create
);
route
.
get
(
'/category'
,
CategoryController
.
index
)
route
.
get
(
'/product'
,
ProductController
.
index
)
export
default
route
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment