Skip to content

kernoio/example-javascript

Repository files navigation

Example JavaScript API

A JavaScript (CommonJS) Express API with Prisma ORM. This is the JavaScript equivalent of the example-typescript project.

Quick Start

# Install dependencies
npm install

# Set up environment
cp env.example .env
# Edit .env with your database credentials

# Generate Prisma client
npx prisma generate

# Run database migrations
npx prisma migrate dev

# Start the server
npm start

Development

# Start with file watching (Node.js 18+)
npm run dev

API Endpoints

  • GET / - Health check
  • POST /api/users - Register
  • POST /api/users/login - Login
  • GET /api/user - Get current user (auth required)
  • PUT /api/user - Update user (auth required)
  • GET /api/profiles/:username - Get profile
  • POST /api/profiles/:username/follow - Follow user (auth required)
  • DELETE /api/profiles/:username/follow - Unfollow user (auth required)
  • GET /api/articles - List articles
  • GET /api/articles/feed - Get feed (auth required)
  • POST /api/articles - Create article (auth required)
  • GET /api/articles/:slug - Get article
  • PUT /api/articles/:slug - Update article (auth required)
  • DELETE /api/articles/:slug - Delete article (auth required)
  • GET /api/articles/:slug/comments - Get comments
  • POST /api/articles/:slug/comments - Add comment (auth required)
  • DELETE /api/articles/:slug/comments/:id - Delete comment (auth required)
  • POST /api/articles/:slug/favorite - Favorite article (auth required)
  • DELETE /api/articles/:slug/favorite - Unfavorite article (auth required)
  • GET /api/tags - Get tags

About

Example project for testing support for javscript with Kerno

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors