|
1 |
| -# Udagram Image Filtering Microservice |
| 1 | +# Udagram REST API |
2 | 2 |
|
3 | 3 | Udagram is a simple cloud application developed alongside the Udacity Cloud Engineering Nanodegree. It allows users to register and log into a web client, post photos to the feed, and process photos using an image filtering microservice.
|
4 | 4 |
|
5 | 5 | The project is split into three parts:
|
6 |
| -1. [The Simple Frontend](https://github.com/grutt/udacity-c2-frontend) |
| 6 | +1. [The Simple Frontend](https://github.com/udacity/cloud-developer/tree/master/course-02/exercises/udacity-c2-frontend) |
7 | 7 | A basic Ionic client web application which consumes the RestAPI Backend.
|
8 |
| -2. [The RestAPI Backend](https://github.com/grutt/udacity-c2-restapi), a Node-Express server which can be deployed to a cloud service. |
9 |
| -3. [The Image Filtering Microservice](https://github.com/grutt/udacity-c2-image-filter), the final project for the course. It is a Node-Express application which runs a simple Python script to process images. |
| 8 | +2. [The RestAPI Backend](https://github.com/udacity/cloud-developer/tree/master/course-02/exercises/udacity-c2-restapi), a Node-Express server which can be deployed to a cloud service. |
| 9 | +3. [The Image Filtering Microservice](https://github.com/udacity/cloud-developer/tree/master/course-02/project/image-filter-starter-code), the final project for the course. It is a Node-Express application which runs a simple script to process images. |
10 | 10 |
|
11 |
| -## Tasks |
12 |
| -### Setup Node Environment |
13 |
| -You'll need to create a new node server. Open a new terminal within the project directory and run: |
14 |
| -1. Initialize a new project: `npm init` |
15 |
| -2. Install express: `npm i express --save` |
16 |
| -3. Install typescript dependencies: `npm i ts-node-dev tslint typescript @types/bluebird @types/express @types/node --save-dev` |
17 |
| -4. Look at the `package.json` file from the RestAPI repo and copy the `scripts` block into the auto-generated `package.json` in this project. This will allow you to use shorthand commands like `npm run dev` |
18 | 11 |
|
19 |
| -### Create a new server.ts file |
20 |
| -Use our basic server as an example to set up this file. For this project, it's ok to keep all of your business logic in the one server.ts file, but you can try to use feature directories and app.use routing if you're up for it. Use the RestAPI structure to guide you. |
| 12 | +*** |
| 13 | +## Getting Setup |
21 | 14 |
|
22 |
| -### Add an endpoint to handle POST /imagetoprocess requests |
23 |
| -It should accept two POST parameter: |
24 |
| -> image_url: string - a public URL of a valid image file |
| 15 | +### Installing project dependencies |
25 | 16 |
|
26 |
| -> upload_image_signedUrl: string (OPTIONAL) - a URL which will allow a PUT request with the processed image |
27 |
| - |
28 |
| -It should respond with 422 unprocessable if either POST parameters are invalid. |
| 17 | +This project uses NPM to manage software dependencies. NPM Relies on the package.json file located in the root of this repository. After cloning, open your terminal and run: |
| 18 | +```bash |
| 19 | +npm install |
| 20 | +``` |
| 21 | +>_tip_: **npm i** is shorthand for **npm install** |
29 | 22 |
|
30 |
| -It should require a token in the Auth Header or respond with 401 unauthorized. |
| 23 | +### Installing useful tools |
| 24 | +#### 1. [Postbird](https://github.com/paxa/postbird) |
| 25 | +Postbird is a useful client GUI (graphical user interface) to interact with our provisioned Postgres database. We can establish a remote connection and complete actions like viewing data and changing schema (tables, columns, ect). |
31 | 26 |
|
32 |
| -It should be versioned. |
| 27 | +#### 2. [Postman](https://www.getpostman.com/downloads/) |
| 28 | +Postman is a useful tool to issue and save requests. Postman can create GET, PUT, POST, etc. requests complete with bodies. It can also be used to test endpoints automatically. We've included a collection (`./udacity-c2-restapi.postman_collection.json `) which contains example requsts. |
33 | 29 |
|
34 |
| -> The matching token should be saved as an environment variable |
35 |
| - |
36 |
| -> (TIP we broke this out into its own auth.router before, but you can access headers as part of the req.headers within your endpoint block) |
| 30 | +*** |
37 | 31 |
|
38 |
| -It should respond with the image as the body if upload_image_signedUrl is included in the request. |
| 32 | +## Running the Server Locally |
| 33 | +To run the server locally in developer mode, open terminal and run: |
| 34 | +```bash |
| 35 | +npm run dev |
| 36 | +``` |
39 | 37 |
|
40 |
| -It should respond with a success message if upload_image_signedUrl is NOT included in the request. |
41 |
| - |
42 |
| - |
43 |
| -### Refactor your RestApi server |
44 |
| -#### Add a request to the image-filter server within the RestAPI POST feed endpoint |
45 |
| - |
46 |
| -It should create new SignedURLs required for the imagetoprocess POST Request body. |
47 |
| - |
48 |
| -It should include a POST request to the new server (TIP keep the server address and token as environment variables). |
49 |
| - |
50 |
| -It should overwrite the image in the bucket with the filtered image (in other words, it will have the same filename in S3). |
51 |
| - |
52 |
| - |
53 |
| -### Deploying your system! |
54 |
| -Follow the process described in the course to `eb init` a new application and `eb create` a new environment to deploy your image-filter service! |
55 |
| - |
56 |
| - |
57 |
| -## Stand Out |
58 |
| -#### Postman Integration Tests |
59 |
| -Try writing a postman collection to test your endpoint. Be sure to cover: |
60 |
| -> POST requests with and without tokens |
61 |
| -> POST requests with valid and invalid parameters |
62 |
| -
|
63 |
| -#### Refactor Data Models |
64 |
| -Try adding another column to your tables to save a separate key for your filtered image. Remember, you'll have to rename the file before adding it to S3! |
| 38 | +Developer mode runs off the TypeScript source. Any saves will reset the server and run the latest version of the codebase. |
65 | 39 |
|
0 commit comments