Nest intial code

This commit is contained in:
Saif Abdelrazek 2025-05-04 06:15:52 +03:00
commit 7b299ae5b5
8 changed files with 2217 additions and 0 deletions

27
modules/shortUrl.js Normal file
View file

@ -0,0 +1,27 @@
import mongoose from "mongoose";
import { nanoid } from "nanoid";
const shortUrlSchema = new mongoose.Schema(
{
full: {
type: String,
required: true,
unique: true,
},
short: {
type: String,
required: true,
unique: true,
default: () => nanoid(6),
},
clicks: {
type: Number,
required: true,
default: 0,
},
},
{ timestamps: true }
);
const ShortUrl = mongoose.model("ShortUrl", shortUrlSchema);
export default ShortUrl;