mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
feat(resources/marketplace): added typings server side
This commit is contained in:
1 parent
aa7919b988
commit
864a6c2402
1 file changed
+6
-11
@@ -4,21 +4,16 @@ import { getSource } from './functions';
|
|||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { usePhoneNumber } from './functions';
|
import { usePhoneNumber } from './functions';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
import { MarketplaceListing } from '../../phone/src/common/typings/marketplace';
|
||||||
|
|
||||||
const selloutLogger = mainLogger.child({ module: 'sellout' });
|
const selloutLogger = mainLogger.child({ module: 'sellout' });
|
||||||
|
|
||||||
interface Listing {
|
|
||||||
title: string;
|
|
||||||
name: string;
|
|
||||||
url?: string;
|
|
||||||
description: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchAllListings(): Promise<Listing[]> {
|
async function fetchAllListings(): Promise<MarketplaceListing[]> {
|
||||||
const query = 'SELECT * FROM npwd_sellout_listings ORDER BY id DESC';
|
const query = 'SELECT * FROM npwd_sellout_listings ORDER BY id DESC';
|
||||||
|
|
||||||
const [results] = await pool.query(query);
|
const [results] = await pool.query(query);
|
||||||
const listings = <Listing[]>results;
|
const listings = <MarketplaceListing[]>results;
|
||||||
|
|
||||||
return listings;
|
return listings;
|
||||||
}
|
}
|
||||||
@@ -27,8 +22,8 @@ async function addListing(
|
|||||||
identifier: string,
|
identifier: string,
|
||||||
name: string,
|
name: string,
|
||||||
number: any,
|
number: any,
|
||||||
listing: Listing
|
listing: MarketplaceListing
|
||||||
): Promise<any> {
|
): Promise<void> {
|
||||||
const query =
|
const query =
|
||||||
'INSERT INTO npwd_sellout_listings (identifier, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?)';
|
'INSERT INTO npwd_sellout_listings (identifier, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?)';
|
||||||
await pool.query(query, [
|
await pool.query(query, [
|
||||||
@@ -53,7 +48,7 @@ onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.SELLOUT_ADD_LISTING, async (listing: Listing) => {
|
onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
const xPlayer = ESX.GetPlayerFromId(_source);
|
||||||
|
|||||||
Reference in new issue
Block a user