Skip to content

Commit

Permalink
Applies GraphQL starter kit logic on Typescript starter
Browse files Browse the repository at this point in the history
- Updates labels in Dockerfile
- Updates gitignore to include schema.gql file
- Adds graphql starter using apollo-server

Signed-off-by: Sean Sundberg <seansund@us.ibm.com>
  • Loading branch information
seansund committed Sep 10, 2021
1 parent bf2ca68 commit ddb62e6
Show file tree
Hide file tree
Showing 35 changed files with 1,609 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ node_modules/
dist/
coverage/
logs/
pacts/
.bluemix/
.helm/
pipeline-build-config.json
test-report.xml
.scannerwork/
schema.gql

# Chart dependencies
**/charts/*.tgz
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ FROM registry.access.redhat.com/ubi8/nodejs-14:1-43

USER default

LABEL name="ibm/template-node-typescript" \
LABEL name="ibm/template-graphql-typescript" \
vendor="IBM" \
version="1" \
release="28.1618434924" \
summary="This is an example of a container image." \
description="This container image will deploy a Typescript Node App"
description="This container image will deploy a Typescript GraphQL App"

WORKDIR /opt/app-root/src

Expand Down
88 changes: 52 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<p align="center">
<a href="http://kitura.io/">
<img src="https://landscape.cncf.io/logos/ibm-member.svg" height="100" alt="IBM Cloud">
Expand All @@ -12,71 +13,86 @@
<img src="https://img.shields.io/badge/license-Apache2-blue.svg?style=flat" alt="Apache 2">
</p>

# TypeScript Microservice or Backend for Frontend with Node.js
# Graphql/Typescript Code Pattern

This is a template repository for a Typescript-based Graphql micro-service.

This app contains an opinionated set of components for modern web development, including:

This Starter Kit Template can be the foundation of a TypeScript Node.js Microservice or Backend for Frontend.

## Getting started

1. Click the 'Use this template' button above or [this link](./generate) to generate a new repository
from this template.
2. Clone the newly created template to your computer
3. Update the project name in the `project.json` file and update the README with the following steps,
run from the root of your project directory:
```bash
mv README.md STARTER-KIT.md
echo "# {project name}" > README.md
```
4. Add and commit the changes to your repo.

## Features

The starter kit provides the following features:

- Built with [TypeScript](https://www.typescriptlang.org/)
- REST services using `typescript-rest` decorators
- Swagger documentation using `typescript-rest-swagger`
- Dependency injection using `typescript-ioc` decorators
- Logging using `bunyan`
- TDD environment with [Jest](https://jestjs.io/)
- Pact testing [Pact](https://docs.pact.io/)
- Jenkins DevOps pipeline that support OpenShift or IKS deployment
* Graphql server from [apollo-server-express](https://github.com/apollographql/apollo-server/tree/main/packages/apollo-server-express)
* Graphql decorators from [type-graphql](https://www.npmjs.com/package/type-graphql)
* Dependency injection using [typescript-ioc](https://www.npmjs.com/package/typescript-ioc) decorators
- Logging using [pino](hhttps://getpino.io/)
- TDD environment with [jest](https://jestjs.io/)
- Pact testing [Pact.io](https://docs.pact.io/)
- DevOps pipeline

#### Native Application Development

Install the latest [Node.js](https://nodejs.org/en/download/) 6+ LTS version.
### Deploying

After you have created a new git repo from this git template, remember to rename the project.
Edit `package.json` and change the default name to the name you used to create the template.

Once the Node toolchain has been installed, you can download the project dependencies with:
Make sure you are logged into the IBM Cloud using the IBM Cloud CLI and have access
to you development cluster. If you are using OpenShift make sure you have logged into OpenShift CLI on the command line.

```bash
npm install
npm run build
npm run start
```$bash
npm i -g @ibmgaragecloud/cloud-native-toolkit-cli
```

### Deploying
Use the IBM Garage for Cloud CLI to register the GIT Repo with Jenkins
```$bash
igc pipeline
```

Make sure you are logged into the IBM Cloud using the IBM Cloud CLI and have access
to your development cluster.
### Building Locally

```$bash
npm i -g @ibmgaragecloud/cloud-native-toolkit-cli
ibmcloud login -a cloud.ibm.com -r <region> -g <resource group>
ibmcloud ks cluster-config --cluster <cluster-name>
kubectl get pods
To get started building this application locally, you can either run the application natively or use the [IBM Cloud Developer Tools](https://cloud.ibm.com/docs/cli?topic=cloud-cli-getting-started) for containerization and easy deployment to IBM Cloud.

```
#### Native Application Development

Use the IBM Garage for Cloud CLI to register the GIT Repo with Jenkins environment
```$bash
oc sync <project> --dev
oc pipeline
Install the latest [Node.js](https://nodejs.org/en/download/) 6+ LTS version.

Once the Node toolchain has been installed, you can download the project dependencies with:

```bash
npm install
cd client; npm install; cd ..
npm run build
npm run start
```

## More Details
To run your application locally:
```bash
npm run start
```

For more details on how to use this Starter Kit Template please review the [IBM Garage for Cloud Developer Tools Developer Guide](https://ibm-garage-cloud.github.io/ibm-garage-developer-guide/)
Your application will be running at `http://localhost:3000`. You can access the `/health` and `/appmetrics-dash` endpoints at the host.

## Next Steps

* Learn more about augmenting your Node.js applications on IBM Cloud with the [Node Programming Guide](https://cloud.ibm.com/docs/node?topic=nodejs-getting-started).
* Explore other [sample applications](https://cloud.ibm.com/developer/appservice/starter-kits) on IBM Cloud.

## License

This sample application is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1](https://developercertificate.org/) and the [Apache License, Version 2](https://www.apache.org/licenses/LICENSE-2.0.txt).

[Apache License FAQ](https://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN)



Loading

0 comments on commit ddb62e6

Please sign in to comment.