Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/fermyon/enterprise-architectures-and-patterns/http-crud-go-sqlite

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/fermyon/enterprise-architectures-and-patterns/http-crud-go-sqlite

  • v0.0.0-20241104133321-aa6fc4054448
  • Source
  • Go
  • Socket score

Version published
Created
Source

HTTP CRUD Sample

This is a sample implementation of CRUD (Create, Read, Update, Delete) in Go.

The sample is using SQLite for persistence and provides the following API endpoints via HTTP:

  • GET /items - To retrieve a list of all items
  • GET /items/:id - To retrieve a item using its identifier
  • POST /items - To create a new item
  • PUT /items/:id - To update an existing item using its identifier
  • DELETE /items/batch - To delete multiple items providing an array of identifiers as payload
  • DELETE /items/:id - To delete an existing item using its identifier

Send data to POST /items and PUT /items/:id using the following structure:

{
    "name": "item name",
    // boolean (either true or false)
    "active": true
}

Prerequisites

To run the sample on your local machine, you must have the following software installed:

  • Latest Spin CLI
  • TinyGo

Running this Sample

Local (spin up)

To run the sample locally, you must provide @migrations.sql using the --sqlite flag to seed the database as shown in the snippet below:

# Build the project
spin build

# Run the sample
spin up --sqlite @migrations.sql
Logging component stdio to ".spin/logs/"
Storing default SQLite data to ".spin/sqlite_db.db"

Serving http://127.0.0.1:3000
Available Routes:
  http-crud-go-sqlite: http://127.0.0.1:3000 (wildcard)

Fermyon Cloud

You can deploy this sample to Fermyon Cloud following the steps below:

# Authenticate
spin cloud login

# Deploy the sample to Fermyon Cloud
# This will ask if a new database should be created or an existing one should be used
# Answer the question with "create a new database"
spin deploy
Uploading http-crud-go-sqlite version 0.1.0 to Fermyon Cloud...
Deploying...
App "http-crud-go-sqlite" accesses a database labeled "default"
    Would you like to link an existing database or create a new database?: Create a new database and link the app to it
What would you like to name your database?
What would you like to name your database?
    Note: This name is used when managing your database at the account level. The app "http-crud-go-sqlite" will refer to this database by the label "default".
    Other apps can use different labels to refer to the same database.: sincere-mulberry
Creating database named 'sincere-mulberry'
Waiting for application to become ready.......... ready

View application:   https://http-crud-go-sqlite-jcmbpezb.fermyon.app/
Manage application: https://cloud.fermyon.com/app/http-crud-go-sqlite

# Ensure tables are created in the new database (here sincere-mulberry)
spin cloud sqlite execute --database sincere-mulberry @migrations.sql

FAQs

Package last updated on 04 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc