Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
I
Internship-uksw-2019 api-document-management
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Internship UKSW 2019
Internship-uksw-2019 api-document-management
Commits
8be44224
Commit
8be44224
authored
Apr 13, 2020
by
Internship UKSW 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
5354b7e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
55 deletions
+52
-55
API.js
routes/API.js
+52
-55
No files found.
routes/API.js
View file @
8be44224
...
@@ -8,52 +8,49 @@ app.use(bodyParser.json())
...
@@ -8,52 +8,49 @@ app.use(bodyParser.json())
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
const
sendEmail
=
(
request
,
response
)
=>
{
const
sendEmail
=
(
request
,
response
)
=>
{
const
{
subject
,
emailcc
,
emailsend
,
message
}
=
request
.
body
const
{
subject
,
emailcc
,
emailsend
,
message
}
=
request
.
body
nodemailer
.
createTestAccount
((
err
,
account
)
=>
{
const
htmlEmail
=
`
const
htmlEmail
=
`
<p>
${
message
}
</p>
<p>
${
message
}
</p>
`
`
let
transporter
=
nodemailer
.
createTransport
({
let
transporter
=
nodemailer
.
createTransport
({
// host: 'smtp.gmail.com',
// host: 'smtp.gmail.com',
// service: 'Gmail',
// service: 'Gmail',
host
:
'mta.visionet.co.id'
,
host
:
'mta.visionet.co.id'
,
port
:
587
,
port
:
587
,
secure
:
false
,
secure
:
false
,
auth
:
{
auth
:
{
user
:
'prastowo.nugroho.int@visionet.co.id'
,
user
:
'prastowo.nugroho.int@visionet.co.id'
,
pass
:
'02Maret2020'
pass
:
'02Maret2020'
},
},
tls
:
{
tls
:
{
rejectUnauthorized
:
false
rejectUnauthorized
:
false
}
}
// debug: true
// debug: true
// auth: {
// auth: {
// user: 'vdocmanagement@gmail.com',
// user: 'vdocmanagement@gmail.com',
// pass: 'docmgmt123'
// pass: 'docmgmt123'
// },
// },
})
})
let
maillist
=
[
let
maillist
=
[
emailsend
emailsend
]
]
maillist
.
forEach
(
function
(
to
,
i
,
array
)
{
maillist
.
forEach
(
function
(
to
,
i
,
array
)
{
let
mailOptions
=
{
let
mailOptions
=
{
from
:
'prastowo.nugroho.int@visionet.co.id'
,
//'vdocmanagement@gmail.com'
from
:
'prastowo.nugroho.int@visionet.co.id'
,
//'vdocmanagement@gmail.com'
cc
:
emailcc
,
cc
:
emailcc
,
subject
:
subject
,
subject
:
subject
,
text
:
message
,
text
:
message
,
html
:
htmlEmail
html
:
htmlEmail
}
mailOptions
.
to
=
to
;
transporter
.
sendMail
(
mailOptions
,
(
error
,
info
)
=>
{
if
(
error
)
{
throw
error
}
}
mailOptions
.
to
=
to
;
// console.log('Message sent:', info.response)
transporter
.
sendMail
(
mailOptions
,
(
error
,
info
)
=>
{
response
.
status
(
200
).
json
({
status
:
'success'
,
message
:
'Email has been sent'
})
if
(
err
)
{
throw
error
}
console
.
log
(
'Message sent: %s'
,
info
.
message
)
console
.
log
(
'Message URL: %s'
,
nodemailer
.
getTestMessageUrl
(
info
))
response
.
status
(
200
).
json
({
status
:
'success'
,
message
:
'Email has been sent'
})
})
})
})
})
})
}
}
...
@@ -94,50 +91,50 @@ const updateDocument = (request, response) => {
...
@@ -94,50 +91,50 @@ const updateDocument = (request, response) => {
}
}
const
deleteDocument
=
(
request
,
response
)
=>
{
const
deleteDocument
=
(
request
,
response
)
=>
{
const
{
doc_id
}
=
request
.
body
const
{
doc_id
}
=
request
.
body
pool
.
query
(
'DELETE FROM document WHERE doc_id = $1'
,
[
doc_id
],
(
error
,
results
)
=>
{
pool
.
query
(
'DELETE FROM document WHERE doc_id = $1'
,
[
doc_id
],
(
error
,
results
)
=>
{
if
(
error
)
{
if
(
error
)
{
throw
error
throw
error
}
}
response
.
status
(
200
).
send
(
`Document deleted with ID:
${
doc_id
}
`
)
response
.
status
(
200
).
send
(
`Document deleted with ID:
${
doc_id
}
`
)
}
}
)
)
}
}
const
deleteRevision
=
(
request
,
response
)
=>
{
const
deleteRevision
=
(
request
,
response
)
=>
{
const
{
doc_id
}
=
request
.
body
const
{
doc_id
}
=
request
.
body
pool
.
query
(
'DELETE FROM revision WHERE doc_id = $1'
,
[
doc_id
],
(
error
,
results
)
=>
{
pool
.
query
(
'DELETE FROM revision WHERE doc_id = $1'
,
[
doc_id
],
(
error
,
results
)
=>
{
if
(
error
)
{
if
(
error
)
{
throw
error
throw
error
}
}
response
.
status
(
200
).
send
(
`Revision deleted with doc_id:
${
doc_id
}
`
)
response
.
status
(
200
).
send
(
`Revision deleted with doc_id:
${
doc_id
}
`
)
}
}
)
)
}
}
const
deleteContent
=
(
request
,
response
)
=>
{
const
deleteContent
=
(
request
,
response
)
=>
{
const
{
cont_id
}
=
request
.
body
const
{
cont_id
}
=
request
.
body
pool
.
query
(
'DELETE FROM content WHERE cont_id = $1'
,
[
cont_id
],
(
error
,
results
)
=>
{
pool
.
query
(
'DELETE FROM content WHERE cont_id = $1'
,
[
cont_id
],
(
error
,
results
)
=>
{
if
(
error
)
{
if
(
error
)
{
throw
error
throw
error
}
}
response
.
status
(
200
).
send
(
`Content deleted with cont_id:
${
cont_id
}
`
)
response
.
status
(
200
).
send
(
`Content deleted with cont_id:
${
cont_id
}
`
)
}
}
)
)
}
}
const
deleteUser
=
(
request
,
response
)
=>
{
const
deleteUser
=
(
request
,
response
)
=>
{
const
{
email
}
=
request
.
body
const
{
email
}
=
request
.
body
pool
.
query
(
'DELETE FROM user_data WHERE email = $1'
,
[
email
],
(
error
,
results
)
=>
{
pool
.
query
(
'DELETE FROM user_data WHERE email = $1'
,
[
email
],
(
error
,
results
)
=>
{
if
(
error
)
{
if
(
error
)
{
throw
error
throw
error
}
}
response
.
status
(
200
).
send
(
`User deleted with Email:
${
email
}
`
)
response
.
status
(
200
).
send
(
`User deleted with Email:
${
email
}
`
)
}
}
)
)
}
}
...
...
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