Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
drive-backend
Overview
Overview
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
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Farhaan Khan
drive-backend
Commits
7375b134
Commit
7375b134
authored
May 05, 2025
by
Farhaan Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fastify api
parent
00fd08ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
index.ts
src/index.ts
+6
-0
db.ts
src/plugins/db.ts
+1
-2
No files found.
src/index.ts
View file @
7375b134
...
...
@@ -7,7 +7,13 @@ const app = Fastify();
app
.
register
(
db
);
app
.
register
(
userRoutes
,
{
prefix
:
'/api/users'
});
app
.
get
(
'/'
,
async
(
request
,
reply
)
=>
{
return
{
message
:
'Fastify server is running!'
};
});
app
.
listen
({
port
:
3001
},
(
err
)
=>
{
if
(
err
)
throw
err
;
console
.
log
(
'Server running on http://localhost:3001'
);
});
src/plugins/db.ts
View file @
7375b134
...
...
@@ -8,14 +8,13 @@ const dbPlugin: FastifyPluginAsync = async (fastify) => {
password
:
'Faruskhan@985'
,
host
:
'localhost'
,
dialect
:
'mysql'
,
models
:
[
__dirname
+
'/../models'
],
// Make sure this path is correct
models
:
[
__dirname
+
'/../models'
],
});
try
{
await
sequelize
.
sync
();
console
.
log
(
'Sequelize connected successfully'
);
// Optionally attach sequelize instance to Fastify
fastify
.
decorate
(
'sequelize'
,
sequelize
);
}
catch
(
err
)
{
console
.
error
(
'Error connecting to DB:'
,
err
);
...
...
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