Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Restack-Joseph

node v16.18.0
version: 1.0.0
endpointsharetweet
const express = require("express"); const util = require("util"); const request = require('request'); const axios = require("axios") const port = 3000; const API_DB_URI = "https://restack-db-e5q273hkis2z.runkit.sh" const ENDPOINTS = { APPLICATIONS: "/applications", CLUSTERS: "/clusters", PROJECTS: "/projects", VOLUMES: "/volumes", WORKLOADS: "/workloads", } // bellow are just examples const APP_NAME = "bij4uwbij4uw-razvan21" const CLUSTER_ID = "c-zvhws" const PROJECT_ID = "c-8gvjh:p-4xjts" const WORKLOADS_ID = "deployment:aipxda:aipxda-airbyte-worker" const VOLUME_ID = "ma6n1q:ma6n1q-mysql" //create our exppress application const app = express(); //declare the root endpoint of the server (accessed using HTTP GET) //have it provide links to our server endpoints app.get('/', (req, res) => { res.status(200).send("ok"); }); /* Exercises: 0 Fix current issue with the code line 54 1 Build an API which query the applications endpoint from API_DB_URI/APPLICATIONS and return the results 2 Build an API where given the name of the application "appName" the API will respond with application data 3 Build an API which returns the cluster, project and application giving an appName 4 Build an API which returns clusters sorted descending by number of pods which can be allocated "allocatable.pods" 6 Build an API which returns the application name and the project name giving VOLIME_ID only if the volume is bound 8 Build an API which returns the workloads grouped by "type" of an application named appName 10 Build an API which returns an application, all the workloads assigned to this application, all the volumes bounded to this application, all the projects belonging to the application and all the clusters which contain this project. */ app.get('/app/:appName', (req, res) => { // const data = await axios.got(`${API_DB_URI}${ENDPOINTS.APPLICATIONS}'`); // const application = { ...data }; // res.status(404).json(response); // console.log(e) }); //Tell our express app to start the server and listen on the given port (3000 in this case); app.listen(port, () => { //print a simple message so we know the server has started up and is listening for requests console.log('Express app is running. Please click the "endpoint" link at the top of the page'); });
Loading…

no comments

    sign in to comment