Skip to content

Commit

Permalink
backup datas
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridwan Zalbina committed Nov 23, 2021
1 parent 3b1d300 commit 9eff959
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 30 deletions.
94 changes: 80 additions & 14 deletions api/api-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,95 @@ const apiDoc = {
version: "1.0.0",
},
definitions: {
Todo: {
Account: {
type: "object",
properties: {
properties: {
id: {
type: "number",
type: "number"
},
message: {
type: "string",
id_card_type: {
type: "number"
},
},
required: ["id", "message"],
},
User: {
type: "object",
properties: {
id: {
email: {
type: "string"
},
username: {
type: "string"
},
nim: {
type: "string"
},
nama: {
type: "string"
},
password: {
type: "string"
},
password_plain: {
type: "string"
},
phone: {
type: "number"
},
tanggal_lahir: {
type: "string"
},
tempat_lahir: {
type: "string"
},
account_type: {
type: "string"
},
namafile: {
type: "string"
},
pendidikan: {
type: "string"
},
name : {
id_prodi : {
type: "string"
},
gender : {
universitas : {
type: "string"
},
fakultas : {
type: "string"
},
jurusan : {
type: "string"
},
tahun_lulus : {
type: "string"
},
comp_bidang_usaha : {
type: "string"
},
comp_deskripsi : {
type: "string"
},
comp_website : {
type: "string"
},
comp_contact_person : {
type: "string"
},
comp_alamat : {
type: "string"
},
date_created : {
type: "number"
},
date_updated : {
type: "number"
},
time_created : {
type: "number"
},
time_updated : {
type: "number"
},
status : {
type: "number"
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions api/config/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mysql = require('mysql');
const connection = mysql.createConnection({
host : "localhost",
user : "root",
password : "",
database : "m2_expo",
port: 3307
});

connection.connect(function(err){
if(err) throw err;
})

module.exports = connection;
50 changes: 34 additions & 16 deletions api/paths/users/index.js → api/paths/account/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const db = require('../../config/database');
const table = 'rexpo_account'
module.exports = function () {
let operations = {
GET,
Expand All @@ -7,10 +9,26 @@ module.exports = function () {
};

function GET(req, res, next) {
res.status(200).json([
{ id: 0, message: "First User" },
{ id: 1, message: "Second User" },
]);
let query = `SELECT id,
id_card,
id_card_type,
email,
username,
nama,
phone,
tanggal_lahir,
tempat_lahir,
account_type,
namafile,
pendidikan FROM `+table+``;
db.query(query, function(error, rows, fields){
if(error){
console.log(error);
res.status(400).json({error: 'Request failed'})
}else{
res.status(200).json(rows);
}
});
}

function POST(req, res, next) {
Expand All @@ -29,31 +47,31 @@ module.exports = function () {
}

GET.apiDoc = {
summary: "Fetch users.",
operationId: "getTodos",
summary: "Fetch account.",
operationId: "getAccount",
responses: {
200: {
description: "List of todos.",
description: "List of account.",
schema: {
type: "array",
items: {
$ref: "#/definitions/Todo",
$ref: "#/definitions/Account",
},
},
},
},
};

POST.apiDoc = {
summary: "Create users.",
operationId: "createTodo",
summary: "Create account.",
operationId: "createAccount",
consumes: ["application/json"],
parameters: [
{
in: "body",
name: "todo",
schema: {
$ref: "#/definitions/Todo",
$ref: "#/definitions/Account",
},
},
],
Expand All @@ -65,8 +83,8 @@ module.exports = function () {
};

PUT.apiDoc = {
summary: "Update users.",
operationId: "updateTodo",
summary: "Update account.",
operationId: "updateAccount",
parameters: [
{
in: "query",
Expand All @@ -78,7 +96,7 @@ module.exports = function () {
in: "body",
name: "todo",
schema: {
$ref: "#/definitions/Todo",
$ref: "#/definitions/Account",
},
},
],
Expand All @@ -90,8 +108,8 @@ module.exports = function () {
};

DELETE.apiDoc = {
summary: "Delete users.",
operationId: "deleteTodo",
summary: "Delete account.",
operationId: "deleteAccount",
consumes: ["application/json"],
parameters: [
{
Expand Down
File renamed without changes.

0 comments on commit 9eff959

Please sign in to comment.