webfast 0.1.70 → 0.1.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = function (array) {
1
+ module.exports = async function (array) {
2
2
  const { readdirSync } = require("fs");
3
3
 
4
4
  console.log(`WebFast!! Program`);
@@ -1,6 +1,6 @@
1
1
  const { MongoClient } = require('mongodb');
2
2
 
3
- module.exports = async function(db, collection, condition, dataToCreate) {
3
+ module.exports = async function(db, collection, condition, dataToCreate,options = {}) {
4
4
  // Ensure the MongoDB connection string is provided
5
5
  if (!process.env.mongo) {
6
6
  console.error('MongoDB connection string not provided. Set process.env.mongo.');
@@ -30,7 +30,7 @@ module.exports = async function(db, collection, condition, dataToCreate) {
30
30
  const collection = database.collection(collectionName);
31
31
 
32
32
  // Check if a document exists based on the condition
33
- const existingDocument = await collection.findOne(condition);
33
+ const existingDocument = await collection.findOne(condition,options);
34
34
 
35
35
  if (existingDocument) {
36
36
  // If a document exists, return it
@@ -43,7 +43,7 @@ module.exports = async function(db, collection, condition, dataToCreate) {
43
43
 
44
44
  if (result.acknowledged === true) {
45
45
  console.log('New document created:', result.insertedId);
46
- const existingDocument = await collection.findOne(condition);
46
+ const existingDocument = await collection.findOne(condition,options);
47
47
  return dataToCreate;
48
48
  } else {
49
49
  console.error('Failed to create a new document.');
@@ -1,6 +1,6 @@
1
1
  const { MongoClient } = require('mongodb');
2
2
 
3
- module.exports = async function (db, collection, condition, dataToUpdate) {
3
+ module.exports = async function (db, collection, condition, dataToUpdate,options = { upsert: true }) {
4
4
  // Ensure the MongoDB connection string is provided
5
5
  if (!process.env.mongo) {
6
6
  console.error('MongoDB connection string not provided. Set process.env.mongo.');
@@ -30,7 +30,7 @@ module.exports = async function (db, collection, condition, dataToUpdate) {
30
30
  const collection = database.collection(collectionName);
31
31
 
32
32
  // Perform the update or create operation
33
- const result = await collection.updateOne(condition, { $set: dataToUpdate }, { upsert: true });
33
+ const result = await collection.updateOne(condition, { $set: dataToUpdate }, options);
34
34
 
35
35
  // If a document was upserted, retrieve the upserted document
36
36
  const upsertedDocument = result.upsertedId
@@ -176,7 +176,7 @@ module.exports = async function (program) {
176
176
  // Now read the dir
177
177
  // Create app.get
178
178
  try {
179
- const theRoute = `/inc/${dirItem}/*`;
179
+ const theRoute = `git pu${dirItem}/*`;
180
180
  app.get(theRoute, async (req, res) => {
181
181
  const params = req.params;
182
182
 
@@ -1,11 +1,13 @@
1
- module.exports = async function(program, url, body) {
1
+ module.exports = async function(program, url, body,headers) {
2
2
  console.log(`Fetch Post`);
3
3
  // Register websocket url
4
4
  try {
5
- const headers = {
6
- accept: 'application/json',
7
- 'content-type': 'application/json'
8
- };
5
+ if (headers == undefined) {
6
+ headers = {
7
+ accept: 'application/json',
8
+ 'content-type': 'application/json'
9
+ };
10
+ }
9
11
 
10
12
  let theOptions = {
11
13
  method: 'POST',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webfast",
3
- "version": "0.1.70",
3
+ "version": "0.1.72",
4
4
  "description": "WebFast! Bot Application, including TON mini-apps for makign it easy and fast to build ini-apps",
5
5
  "main": "index.js",
6
6
  "repository": {