Back to articles
Nitric Has a Free API: Build Cloud-Agnostic Serverless Apps in TypeScript
How-ToDevOps

Nitric Has a Free API: Build Cloud-Agnostic Serverless Apps in TypeScript

via Dev.to TutorialAlex Spinov

What is Nitric? Nitric is a cloud-agnostic serverless framework that lets you build applications without locking into AWS, GCP, or Azure. Define your resources in code — deploy to any cloud with a single command. Quick Start npm install -g @nitric/cli nitric new my-app ts-starter cd my-app npm install nitric start Define APIs import { api } from " @nitric/sdk " ; const mainApi = api ( " main " ); mainApi . get ( " /users/:id " , async ( ctx ) => { const { id } = ctx . req . params ; const user = await getUser ( id ); ctx . res . json ( user ); }); mainApi . post ( " /users " , async ( ctx ) => { const body = ctx . req . json (); const user = await createUser ( body ); ctx . res . status = 201 ; ctx . res . json ( user ); }); mainApi . delete ( " /users/:id " , async ( ctx ) => { await deleteUser ( ctx . req . params . id ); ctx . res . status = 204 ; }); Key-Value Storage import { kv } from " @nitric/sdk " ; const profiles = kv ( " profiles " ). allow ( " get " , " set " , " delete " )

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
2 views

Related Articles