Coding Bootcamp Week 7: Backend Project, Async Await & CICD

Backend development

Reem Dalvi
4 min readFeb 26, 2023
Used Kanban for project workflow management

Backend Project — News API ✨

For my backend project I chose to create a news API that allows users to retrieve information on topics, articles, users and comments.

I set up an instance of my database using ElephantSQL and hosted my API using Render.

You can check out my GitHub repo for more info.

Async/Await ⏲

The async / await pattern is syntactic sugar which allows promise-based asynchronicity to be written in a way that looks like synchronous code. It is much easier to read and understand and helps you avoid callback hell.

The keyword is used to declare a function as asynchronous. When a function is marked as async, it always returns a promise. Inside an async function, you can use the await keyword to wait for the completion of an asynchronous operation before proceeding with the next line of code. The await keyword can only be used inside an async function.

async function getSomeData() {
const data = await fetchData();
return data;
}

getSomeData()
.then(data => console.log(data))
.catch(error => console.error(error));

In the code above, fetchData() returns a promise, the await keyword is used to wait for the promise to resolve and return the result.

Once the result is available, it is assigned to the data variable, and then the function returns the data.

Then getSomeData() function is called and the results is logged to the console and if an error occurs then the error is logged instead.

It could also be written in a try / catch block as below.

async function main() {
try {
const data = await getSomeData();
console.log(data);
} catch (error) {
console.error(error);
}
}

main();

CICD

CI/CD stands for Continuous Integration and Continuous Delivery/Deployment, and it is an approach to software development that involves automating the testing and delivery of code changes.

The goal of CI/CD is to enable faster, more frequent releases of software with higher quality and less risk. It does this by automating the process of building, testing, and deploying code changes, making it possible to quickly detect and fix issues before they become major problems.

Here is an example workflow for implementing CI/CD:

  1. Developer writes code and pushes changes to GitHub repository.
  2. CI server detects changes and pulls code from GitHub.
  3. CI server runs automated tests to ensure code quality.
  4. If tests pass, the CI server automatically builds and packages the code.
  5. CD server deploys the new code package to a staging environment.
  6. QA team performs additional testing and verifies the code quality.
  7. If the code passes testing, CD server deploys the code to production.

GitHub Actions is a powerful tool for automating software workflows. You can use it to create a continuous integration and delivery (CI/CD) pipeline that automatically builds, tests, and deploys your code to a target environment whenever changes are made to the repository.

Emotional check 💻

This has been an incredible week for me, I’ve had numerous deep work sessions, resulting in a high level of productivity.

Even though we have previously worked on smaller functions with specific purposes, this week I got to witness the code come to life and comprehend how everything fits together. Plus, I now possess the ability to construct an API from scratch.

However, we are starting with frontend development next week, and I feel like I haven’t explored the backend fully yet. I found it extremely satisfying to create the server-side logic, and I wish to delve deeper into it.

That being said, I am also excited to work on the frontend as it will provide me with an opportunity to unleash my creative side. 🌱

Leap through time

--

--

Reem Dalvi

I like finding parallels between biological and computer science