Skip to content

Commit

Permalink
post udpated
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridwan Zalbina committed Nov 23, 2021
1 parent 9eff959 commit 2eb0406
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
24 changes: 24 additions & 0 deletions api/paths/api/account/`INSERT INTO "rexpo_account" (.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
`INSERT INTO "rexpo_account" (
'id', 'id_card', 'id_card_type', 'email',
'username', 'nim', 'nama', 'password',
'password_plain', 'phone', 'tanggal_lahir',
'tempat_lahir', 'account_type',
'namafile', 'pendidikan', 'id_prodi',
'universitas', 'fakultas', 'jurusan',
'tahun_lulus', 'comp_bidang_usaha',
'comp_deskripsi', 'comp_website',
'comp_contact_person', 'comp_alamat',
'date_created', 'date_updated',
'time_created', 'time_updated',
'status'
)
VALUES
(
NULL, NULL, NULL, 'admeventfkunsri3@gmail.com',
NULL, '', 'Admins', '25d55ad283aa400af464c76d713c07ad',
'', '82122334455', NULL, NULL, 'admin',
NULL, NULL, '0', NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, '', '2021-06-18',
'2021-06-18', '14:07:24', '14:07:24',
'1'
)`
28 changes: 16 additions & 12 deletions api/paths/account/index.js → api/paths/api/account/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const db = require('../../config/database');
const db = require('../../../config/database');
const table = 'rexpo_account'
module.exports = function () {
let operations = {
Expand Down Expand Up @@ -32,8 +32,21 @@ module.exports = function () {
}

function POST(req, res, next) {
console.log(`About to create todo: ${JSON.stringify(req.body)}`);
res.status(201).send();
let email = req.body.email;
let nama = req.body.nama;
let password = req.body.password;
let account_type = req.body.account_type;
let date_created =
let query = `INSERT INTO rexpo_account (email, nama, password, phone, account_type, date_created, date_updated, time_created,time_updated)
VALUES('zbinaridwan@gmail.com','M. Ridwan Zalbina', '25d55ad283aa400af464c76d713c07ad', '081919992000', 'peserta', '2021-06-18','2021-06-18','14:09:08','14:09:08')`;
db.query(query, function(error, rows, field){
if(error){
console.log(error);
res.status(400).json({error: 'Request failed'})
}else{
res.status(200).json(rows);
}
});
}

function PUT(req, res, next) {
Expand Down Expand Up @@ -66,15 +79,6 @@ module.exports = function () {
summary: "Create account.",
operationId: "createAccount",
consumes: ["application/json"],
parameters: [
{
in: "body",
name: "todo",
schema: {
$ref: "#/definitions/Account",
},
},
],
responses: {
201: {
description: "Created",
Expand Down
Empty file added api/paths/api/forms/index.js
Empty file.
15 changes: 15 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ initialize({
paths: "./api/paths",
});

// Not found routes
app.get('/', function(req, res){
res.send({
'status' : 400,
'message' : 'Invalid Request'
}, 404);
});

// Default routes
app.use((err, req, res, next) => {
if (err.name === 'UnauthorizedError') {
res.status(500).send(err.message);
}
});

// OpenAPI UI
app.use(
"/api-documentation",
Expand Down

0 comments on commit 2eb0406

Please sign in to comment.