Git Product home page Git Product logo

adonis-mongorito's Introduction

Olá, sou Allan Silva de Freitas! :D

Github Badge Linkedin Badge Twitter Badge

Sobre Mim

Sou um desenvolvedor {Backend, Frontend e Mobile} e Mentor(sempre que possível).

  • 🔭 Trabalhando atualmente: Projetos Privados usando PHP/Laravel, ReactJS, Java/SpringBoot, Oracle, SqlServer, Mysql, Linux, ReactNative ...
  • 🌱 Estou estudando atualmente: Java/SpringBoot REST, C#/.Net Core, Angular
  • 🤔 Procurando ajuda para: Ganhar R$20k mensal líquido :) se tiver dicas entre em contato por favor
  • 💬 Quer conversar sobre Desenvolvimento, Administração de Servidores e Música em geral? Entre em contato
  • 📫 Como entrar em contato: manda mensagem no twitter ou no email allanfreitasci(sabe o que vai aqui né?)gmail.com

Mais Info?

adonis-mongorito's People

Contributors

allanfreitas avatar oscarnevarezleal avatar thetutlage avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

adonis-mongorito's Issues

Support for SSL options

I needed to set up a connection to mongo using the SSL options to authenticate. Based on options available from http://mongodb.github.io/node-mongodb-native/2.2/tutorials/connect/ssl/ here's how i've done it:

Relevant .env part:

MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_USER=root
MONGO_PASS=123456
MONGO_DATABASE=test

MONGO_VERIFY_HOSTNAME=false

MONGO_SSL=true
MONGO_CRT=/etc/ssl/certs/mongo-pem
MONGO_KEY=/etc/ssl/certs/mongo-pem
MONGO_CA=/etc/ssl/certs/mongo-ca

All config/mongo.js:

'use strict'

const fs = require('fs')

const Env = use('Env')

let ssl    = Env.get('MONGO_SSL', false);
let crt    = Env.get('MONGO_CRT', '');
let key    = Env.get('MONGO_KEY', '');
let ca     = Env.get('MONGO_CA', '');

if (ssl) {
  if (crt && fs.existsSync(crt)) {
    crt = fs.readFileSync(crt)
  }

  if (key && fs.existsSync(key)) {
    key = fs.readFileSync(key)
  }

  if (ca && fs.existsSync(ca)) {
    ca = [fs.readFileSync(ca)]
  }
}

module.exports = {
  host:   Env.get('MONGO_HOST'),
  port:   Env.get('MONGO_PORT'),
  user:   Env.get('MONGO_USER', ''),
  pass:   Env.get('MONGO_PASS', ''),
  db:     Env.get('MONGO_DATABASE'),
  verify: Env.get('MONGO_VERIFY_HOSTNAME', false),
  ssl:    ssl,
  crt:    crt,
  key:    key,
  ca:     ca
}

and I had to change MongoritoProvider.js file, MongoritoProvider class declaration only:

class MongoritoProvider extends ServiceProvider {

  * register () {
    this.app.singleton('Adonis/Addons/MongoritoModel', function (app) {
      let Config = app.use('Adonis/Src/Config')

      const mongoHost = Config.get('mongo.host')
      const mongoPort = Config.get('mongo.port')
      const mongoUser = Config.get('mongo.user')
      const mongoPass = Config.get('mongo.pass')

      let mongoDb = Config.get('mongo.db')
      let mongoVerify = Config.get('mongo.verify')

      let mongoSSL = Config.get('mongo.ssl')
      let mongoKey = Config.get('mongo.key')
      let mongoCrt = Config.get('mongo.crt')
      let mongoCa = Config.get('mongo.ca')

      let options = { server: {} }

      if (mongoSSL) {
        mongoDb = `${mongoDb}?ssl=true`

        options.server.sslValidate = true;
        options.server.sslKey      = mongoKey;
        options.server.sslCert     = mongoCrt;
        options.server.sslCA       = mongoCa;
      }

      options.server.checkServerIdentity = mongoVerify;

      const connectUri = `${mongoHost}:${mongoPort}/${mongoDb}`
      const connectionString = (mongoUser !== '' || mongoPass !== '') ? `${mongoUser}:${mongoPass}@${connectUri}` : connectUri

      logger.verbose('connection string %s', connectionString)
      Mongorito.connect(connectionString, options)

      return MongoritoModel
    })
  }
}

I don't wanna lose my changes on the MongoritoProvider next time I run npm update. So how can we arranged so this gets fixed? Do I submit a PR? Or would you change it?

orderBy

Can you tell me the correct systax for orderBy? I am trying following:

yield Post.orderBy('date_time', 'desc').findOne();

Missing directorys

After a fresh install,
npm install
the AuthManager and the Serializer Folder is missing in the adonis-mongorito folder

jwt and MongoritoScheme

I have a question about the usage with adonis auth jwt.
In your docs stay , that for scheme we should add the "MongoritoScheme"

The following its to add the Authenticator combination so you can perform Mongo db check in authentication.

  // change here if you are using jwt, otherwise change it in you right authenticator
  jwt: {
    serializer: 'MongoritoSerializer', // this is new
    model: 'App/Model/User',
    scheme: 'MongoritoScheme', // and this too
    uid: 'username',
    password: 'password',
    secret: Config.get('app.appKey')
  }

But i think in the jwt block, the "scheme" value must stay at "jwt".
The 'MongoritoScheme' seems to be worked only if you use auth sessions
Is that correct?

if i use 'MongoritoScheme', i get an "generate is not a function..." error on generating an token with;

const token = yield request.auth.generate(user)

Cannot find module 'adonis-fold'

After installing the adonis-mongorito module and adding adonis-mongorito/providers/MongoritoProvider to the app.js file I am getting the following error:

{ Error: Cannot find module 'adonis-fold'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/jgardner/Git/CouchWalrus/src/couchWalrus/node_modules/adonis-mongorito/providers/MongoritoProvider.js:3:25)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3) code: 'MODULE_NOT_FOUND' }

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.