This commit is contained in:
2026-01-26 17:56:52 +07:00
parent 156cdefaba
commit 713efb81b5
2 changed files with 89 additions and 40 deletions

53
dist/places.js vendored
View File

@@ -1,31 +1,35 @@
import Geohash from 'latlon-geohash';
import { ulid } from 'ulid';
const placeSchema = {
type: 'object',
properties: {
id: { type: 'string' },
title: { type: 'string' },
lat: { type: 'number' },
lon: { type: 'number' },
geohash: { type: 'string' },
zoom: { type: 'number' },
url: { type: 'string' },
osmId: { type: 'string' },
osmType: { type: 'string' },
osmTags: {
type: 'object',
additionalProperties: { type: 'string' },
},
description: { type: 'string' },
tags: {
type: 'array',
items: { type: 'string' },
default: [],
},
createdAt: { type: 'string', format: 'date-time' },
updatedAt: { type: 'string', format: 'date-time' },
},
required: ['id', 'title', 'lat', 'lon', 'geohash', 'createdAt'],
};
const Places = function (privateClient /*, publicClient: BaseClient */) {
// Define Schema
privateClient.declareType('place', {
type: 'object',
properties: {
id: { type: 'string', required: true },
title: { type: 'string', required: true },
lat: { type: 'number', required: true },
lon: { type: 'number', required: true },
geohash: { type: 'string', required: true },
zoom: { type: 'number' },
url: { type: 'string' },
osmId: { type: 'string' },
osmType: { type: 'string' },
osmTags: { type: 'object' },
description: { type: 'string' },
tags: {
type: 'array',
items: { type: 'string' },
default: [],
},
createdAt: { type: 'string', format: 'date-time', required: true },
updatedAt: { type: 'string', format: 'date-time' },
},
required: ['id', 'title', 'lat', 'lon', 'geohash', 'createdAt'],
});
privateClient.declareType('place', placeSchema);
// Helper to normalize place object
function preparePlace(data) {
const now = new Date().toISOString();
@@ -44,6 +48,7 @@ const Places = function (privateClient /*, publicClient: BaseClient */) {
lon,
geohash,
title,
tags: data.tags || [],
createdAt: data.createdAt || now,
updatedAt: data.id ? now : undefined,
};