Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues loading on first setup #54

Closed
Aghassi opened this issue Mar 8, 2017 · 2 comments
Closed

Issues loading on first setup #54

Aghassi opened this issue Mar 8, 2017 · 2 comments

Comments

@Aghassi
Copy link

Aghassi commented Mar 8, 2017

Hello!

I've been trying to follow the README to get this working locally before trying it in prod, but I can't seem to get my data to load into the database at all. So far, my code looks like this:

var GTFS = require('gtfs-sequelize');

var downloadConfig = {
  gtfsUrl: 'http://transitfeeds.com/p/nj-transit/409/latest/download',
  downloadsDir: 'downloads'
};

var gtfs = GTFS(downloadConfig);
gtfs.downloadGtfs(function() {
  //download has finished callback
  console.log("Download complete, adding gtfs to database.");
  var pgConfig = {
    database: 'postgres://gtfs_sequelize:gtfs_sequelize@localhost:5432/gtfs-sequelize-test',
    downloadsDir: 'downloads',
    gtfsFilename: 'gtfs.zip',
    sequelizeOptions: {
      logging: false
    }
  };

  var gtfs = GTFS(pgConfig);
  gtfs.loadGtfs(function() {
    //database loading has finished callback
    console.log("Finished loading to database");
  });
});

However, I keep receiving the following error:

path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined

What exactly am I doing wrong here? I'm using node version lts/boron if that helps.

@evansiroky
Copy link
Owner

Thanks for reporting.

Unfortunately a lot is going on here that is the fault of this library.

  1. The README docs are wrong and need to be updated. The config option gtfsFilename should be gtfsFileOrFolder.
  2. The url you are querying does a redirect to the actual file, which this library doesn't yet support
  3. The url it redirects to downloads via https, which this library can't handle
  4. This particular feed is the kind that omits the calendar.txt file and instead includes everything in calendar_dates.txt. This library also can't handle that, but at least that is a know issue (Error encountered on fresh db when using gtfs with only calendar_dates.txt #53)

I should probably work on fixes for all these things, but it's low priority for me at the moment. If you want to take a shot at it I'm happy to accept a PR.

evansiroky added a commit that referenced this issue Jan 5, 2018
download should resolve issue of being unable to use https and should
follow redirects.  Refs #54

Removing test for defunct ftp download.
@evansiroky
Copy link
Owner

These issues should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants