Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-029
2023-029
Commits
1f76f5f0
Commit
1f76f5f0
authored
May 18, 2023
by
supundileepa00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Video upload backend development
parent
f04ec589
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
356 additions
and
19 deletions
+356
-19
Project/Backend/Server_Node/controllers/translate.controller.js
...t/Backend/Server_Node/controllers/translate.controller.js
+42
-0
Project/Backend/Server_Node/package-lock.json
Project/Backend/Server_Node/package-lock.json
+272
-0
Project/Backend/Server_Node/package.json
Project/Backend/Server_Node/package.json
+1
-0
Project/Backend/Server_Node/routes/translate.routes.js
Project/Backend/Server_Node/routes/translate.routes.js
+8
-0
Project/Backend/Server_Node/server.js
Project/Backend/Server_Node/server.js
+21
-19
Project/Backend/Server_Node/service/videoService.js
Project/Backend/Server_Node/service/videoService.js
+12
-0
No files found.
Project/Backend/Server_Node/controllers/translate.controller.js
0 → 100644
View file @
1f76f5f0
import
multer
from
"
multer
"
;
import
videoService
from
"
../service/videoService.js
"
;
const
storage
=
multer
.
diskStorage
({
destination
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
"
uploads/
"
);
},
filename
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
Date
.
now
()
+
"
-
"
+
file
.
originalname
);
},
});
const
upload
=
multer
({
storage
:
storage
}).
single
(
"
video
"
);
export
function
uploadVideo
(
req
,
res
)
{
upload
(
req
,
res
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
return
res
.
status
(
500
)
.
send
(
"
An error occurred while uploading the video
"
);
}
if
(
!
req
.
file
)
{
return
res
.
status
(
400
).
send
(
"
No video file provided
"
);
}
res
.
status
(
200
).
send
({
status
:
true
,
message
:
"
Translated Text
"
,
data
:
"
ආආආආආආආආආ
"
,
});
// videoService
// .processVideo(req.file)
// .then(() => res.status(200).send("Video uploaded successfully"))
// .catch((error) => {
// console.error(error);
// res.status(500).send("An error occurred while processing the video");
// });
});
}
Project/Backend/Server_Node/package-lock.json
View file @
1f76f5f0
This diff is collapsed.
Click to expand it.
Project/Backend/Server_Node/package.json
View file @
1f76f5f0
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
"express"
:
"^4.18.2"
,
"express"
:
"^4.18.2"
,
"jsonwebtoken"
:
"^9.0.0"
,
"jsonwebtoken"
:
"^9.0.0"
,
"mongoose"
:
"^7.1.1"
,
"mongoose"
:
"^7.1.1"
,
"multer"
:
"^1.4.5-lts.1"
,
"nodemailer"
:
"^6.9.1"
,
"nodemailer"
:
"^6.9.1"
,
"nodemon"
:
"^2.0.22"
,
"nodemon"
:
"^2.0.22"
,
"uuid"
:
"^9.0.0"
"uuid"
:
"^9.0.0"
...
...
Project/Backend/Server_Node/routes/translate.routes.js
0 → 100644
View file @
1f76f5f0
import
express
from
"
express
"
;
import
{
uploadVideo
}
from
"
../controllers/translate.controller.js
"
;
const
router
=
express
.
Router
();
router
.
post
(
"
/upload
"
,
uploadVideo
);
export
default
router
;
Project/Backend/Server_Node/server.js
View file @
1f76f5f0
...
@@ -6,6 +6,7 @@ import mongoose from "mongoose";
...
@@ -6,6 +6,7 @@ import mongoose from "mongoose";
//import routes
//import routes
import
userRoutes
from
"
./routes/user.routes.js
"
;
import
userRoutes
from
"
./routes/user.routes.js
"
;
import
translateRoutes
from
"
./routes/translate.routes.js
"
;
dotenv
.
config
();
dotenv
.
config
();
const
app
=
express
();
const
app
=
express
();
...
@@ -21,6 +22,7 @@ app.get("/", (req, res) => {
...
@@ -21,6 +22,7 @@ app.get("/", (req, res) => {
//implement routes
//implement routes
app
.
use
(
"
/rest_node/user
"
,
userRoutes
);
app
.
use
(
"
/rest_node/user
"
,
userRoutes
);
app
.
use
(
"
/rest_node/ssl
"
,
translateRoutes
);
const
CONNECTION_URL
=
`mongodb+srv://
${
process
.
env
.
DB_USERNAME
}
:
${
process
.
env
.
DB_PASSWORD
}
@cluster0.dmza8yi.mongodb.net/?retryWrites=true&w=majority`
;
const
CONNECTION_URL
=
`mongodb+srv://
${
process
.
env
.
DB_USERNAME
}
:
${
process
.
env
.
DB_PASSWORD
}
@cluster0.dmza8yi.mongodb.net/?retryWrites=true&w=majority`
;
const
PORT
=
process
.
env
.
PORT
||
5000
;
const
PORT
=
process
.
env
.
PORT
||
5000
;
...
@@ -42,5 +44,5 @@ mongoose
...
@@ -42,5 +44,5 @@ mongoose
app
.
use
((
err
,
req
,
res
,
next
)
=>
{
app
.
use
((
err
,
req
,
res
,
next
)
=>
{
console
.
error
(
err
.
stack
);
console
.
error
(
err
.
stack
);
res
.
status
(
500
).
send
(
'
Internal Server Error
'
);
res
.
status
(
500
).
send
(
"
Internal Server Error
"
);
});
});
Project/Backend/Server_Node/service/videoService.js
0 → 100644
View file @
1f76f5f0
export
default
function
processVideo
(
videoFile
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// Perform video processing tasks here
// Example: store videoFile in a database, generate thumbnails, etc.
// Simulating asynchronous processing
setTimeout
(()
=>
{
// Resolve the promise to indicate successful processing
resolve
();
},
2000
);
});
}
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