GithubHelp home page GithubHelp logo

nodejs-pure's People

Contributors

conmute avatar jaoodxd avatar tshemsedinov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nodejs-pure's Issues

Possible SQL Injection

В файле db.js присутствует следующий код

async read(id, fields = ['*']) {
    const names = fields.join(', ');
    const sql = `SELECT ${names} FROM ${table}`;
    if (!id) return pool.query(sql);
    return pool.query(`${sql} WHERE id = $1`, [id]);
}

Здесь может быть уязвимость связанная с SQL инъекцией. Поскольку запрос в базу данных использует конкатенацию строк, которые ни как не валидируются. Конечно уязвимость зависит от того, как этим методом пользоваться. Но вдруг кто то вызовет его не так, как нам хочется.

Error proposal

There was a discussion about custom domain errors at the course meeting (QA 28/02/2023).
Proposed variants were separate class per error or general DomainError class with an internal map of allowed messages.

Instead, I propose having one class per domain with factories of allowed errors.

class DomainError extends Error {
...
}

class MessengerError extends DomainError {
...

  static invalidPermission() {
    return new MessengerError('Permission denied');
  }
  
  static notFound() {
    return new MessengerError('Not found');
  }
  
  // and so on...
}

This neither requires defining a class per each error (1 proposal) nor requires additional functionality to check if a general purpose error received an allowed message (2 proposal).
This also adds static checks and autocompletion.

Корректное ли название функции?

Здравствуйте, подскажите пожалуйста, почему функция называется serveStatic, ведь по сути она ничего не сервает? Ну то есть сервер в ней не создается, дальше по коду, где она используется в классе, мы ее кладем в метод this.staticHandler = serveStatic(staticPath);
Возможно эту функцию корректнее назвать staticHandler?

const serveStatic = (staticPath) => async (req, res) => {

Wrong root directory for application's endpoints

As it was discussed in the meeting, API endpoints from Nodejs-Application have wrong root directory(Nodejs-Pure directory).
For example this endpoint. In this case fs thinks he is in Nodejs-Pure directory just now and upoaded file will be written simple in the NodeJs-Pure.
So the resolve of this problem is just to change root path in vm Sandbox.

issues to accessing the 'lib' and 'domain' folders

I attempted to organize the code structure in my pet project based on the examples from this repository: https://github.com/metatech-university/NodeJS-Application/pull/4/files. However, I faced issues with accessing the 'lib' and 'domain' folders.

To fix this, I added the following code to my main.js file:

const sandbox = {
  console, common, api, db: null, lib: {}, domain: {}
};

sandbox.lib = Object.freeze(await loadDir(libPath, sandbox));
sandbox.domain = Object.freeze(await loadDir(domainPath, sandbox));

However, this approach caused issues where the 'domain' folder was not visible from the 'lib' folder, and neither folder could access itself. But from api folder have a access for both folder

For example, I had a function located in the 'domain' folder at domain/Chat/get.js:

async (ctx, name) => {
const { repository } = domain.Chat;

const chat = await repository.get(ctx, name);
if (!chat) throw new domain.Errors.NotFoundError('No such chat', { name });
return chat;
};

This function attempted to retrieve a repository from the 'domain/Chat/repository/get.js' module, but returned 'undefined'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.