generated from cloud-gov/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cloudfoundry page and api endpoints
This does not persist the cf auth token in any way
- Loading branch information
Showing
7 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
node_modules | ||
|
||
# NextJS env files | ||
.env.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/***/ | ||
// API library for cloud foundry requests | ||
/***/ | ||
import { getData } from './api'; | ||
|
||
const CF_API_URL = process.env.CF_API_URL; | ||
const CF_API_TOKEN = process.env.CF_API_TOKEN; | ||
|
||
export async function getCFApps() { | ||
try { | ||
const body = await getData(CF_API_URL + "/apps", { | ||
headers: { | ||
"Authorization": CF_API_TOKEN | ||
} | ||
}); | ||
if (body.resources) { | ||
return body.resources; | ||
} else { | ||
throw new Error("resources not found"); | ||
} | ||
} catch (error) { | ||
throw new Error(error.message); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getCFApps } from '../../../api/cloudfoundry'; | ||
|
||
export default async function CloudFoundryAppsPage() { | ||
try { | ||
const apps = await getCFApps(); | ||
return ( | ||
<> | ||
<h1>Your CF Apps</h1> | ||
<ul>{apps.map(app => ( | ||
<li key={app.guid}>{app.name}</li> | ||
))}</ul> | ||
</> | ||
) | ||
} catch (error) { | ||
return( | ||
<div role='alert'>{ error.message }</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Link from 'next/link'; | ||
|
||
export default function CloudFoundryPage() { | ||
return( | ||
<> | ||
<h1>Cloud Foundry Functions</h1> | ||
<ul> | ||
<li><Link href="/cloudfoundry/apps">apps list</Link></li> | ||
</ul> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters