Create event with API and load event details
This commit is contained in:
parent
855477570f
commit
8e5954e0ca
19 changed files with 349 additions and 58 deletions
|
|
@ -2,6 +2,7 @@ require('dotenv').config();
|
|||
|
||||
const { Datastore } = require('@google-cloud/datastore');
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
|
||||
const package = require('./package.json');
|
||||
|
||||
|
|
@ -20,6 +21,9 @@ const datastore = new Datastore({
|
|||
keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS,
|
||||
});
|
||||
|
||||
app.use(cors({
|
||||
origin: 'http://localhost:3000',
|
||||
}));
|
||||
app.use(express.json());
|
||||
app.use((req, res, next) => {
|
||||
req.datastore = datastore;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
"dependencies": {
|
||||
"@google-cloud/datastore": "^6.3.1",
|
||||
"bcrypt": "^5.0.1",
|
||||
"cors": "^2.8.5",
|
||||
"dayjs": "^1.10.4",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1"
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ module.exports = async (req, res) => {
|
|||
try {
|
||||
const query = req.datastore.createQuery(['__Stat_Kind__']);
|
||||
|
||||
eventCount = (await req.datastore.runQuery(query.filter('kind_name', 'Event')))[0].count;
|
||||
personCount = (await req.datastore.runQuery(query.filter('kind_name', 'Person')))[0].count;
|
||||
eventCount = (await req.datastore.runQuery(query.filter('kind_name', 'Event')))[0][0].count;
|
||||
personCount = (await req.datastore.runQuery(query.filter('kind_name', 'Person')))[0][0].count;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,6 +306,14 @@ core-util-is@~1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
||||
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
|
||||
|
||||
cors@^2.8.5:
|
||||
version "2.8.5"
|
||||
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
|
||||
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
|
||||
dependencies:
|
||||
object-assign "^4"
|
||||
vary "^1"
|
||||
|
||||
dayjs@^1.10.4:
|
||||
version "1.10.4"
|
||||
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2"
|
||||
|
|
@ -851,7 +859,7 @@ number-is-nan@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
|
||||
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
|
||||
|
||||
object-assign@^4.1.0:
|
||||
object-assign@^4, object-assign@^4.1.0:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||
|
|
@ -1180,7 +1188,7 @@ utils-merge@1.0.1:
|
|||
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
||||
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
||||
|
||||
vary@~1.1.2:
|
||||
vary@^1, vary@~1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
|
||||
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue